2016-10-21 11 views
0

おはようございます:証明書を使用してJavaプロジェクトのWebサービスに接続します。

私は配備しているサーバーに接続するにはいくつかの問題があります。

まず、私が管理しているサーバにwsdlというWebサービスがあります。 そして、私はjavaクライアントをプログラミングして、httpsを介して8443ポートと接続して、ウェブサービスをTomcatのWebサービスに接続してデータを返します。

私は最初にサーバにpfx証明書をインストールしました。これは動作します。

第2に、ブラウザからクライアントの.cer証明書ファイルをダウンロードしました。これを使用して、Webサービスhttpsを8443で呼び出す必要があり、常に同じエラーが発生しています。

AxisFault 
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException 
faultSubcode: 
faultString: javax.ws.rs.ProcessingException: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 
faultActor: 
faultNode: 
faultDetail: 
    {http://xml.apache.org/axis/}hostname:vm6145260 

javax.ws.rs.ProcessingException: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 
    at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222) 
    at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129) 
    at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087) 
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source) 
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source) 
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source) 
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source) 
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source) 
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) 
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) 
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) 
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) 
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source) 
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) 
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(Unknown Source) 
    at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227) 
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696) 
    at org.apache.axis.Message.getSOAPEnvelope(Message.java:435) 
    at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62) 
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206) 
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784) 
    at org.apache.axis.client.Call.invoke(Call.java:2767) 
    at org.apache.axis.client.Call.invoke(Call.java:2443) 
    at org.apache.axis.client.Call.invoke(Call.java:2366) 
    at org.apache.axis.client.Call.invoke(Call.java:1812) 
    at com.b7f2.ws.service.ImplLoginSoapBindingStub.validaLogin(ImplLoginSoapBindingStub.java:157) 
    at com.b7f2.ws.service.ImplLoginProxy.validaLogin(ImplLoginProxy.java:51) 
    at com.b7f2.ws.client.WindowPrincipal.enviarMatricula(WindowPrincipal.java:105) 
    at com.b7f2.ws.client.WindowPrincipal.access$1(WindowPrincipal.java:97) 
    at com.b7f2.ws.client.WindowPrincipal$2.actionPerformed(WindowPrincipal.java:216) 
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) 
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) 
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) 
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source) 
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) 
    at java.awt.Component.processMouseEvent(Unknown Source) 
    at javax.swing.JComponent.processMouseEvent(Unknown Source) 
    at java.awt.Component.processEvent(Unknown Source) 
    at java.awt.Container.processEvent(Unknown Source) 
    at java.awt.Component.dispatchEventImpl(Unknown Source) 
    at java.awt.Container.dispatchEventImpl(Unknown Source) 
    at java.awt.Component.dispatchEvent(Unknown Source) 
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) 
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) 
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) 
    at java.awt.Container.dispatchEventImpl(Unknown Source) 
    at java.awt.Window.dispatchEventImpl(Unknown Source) 
    at java.awt.Component.dispatchEvent(Unknown Source) 
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source) 
    at java.awt.EventQueue.access$500(Unknown Source) 
    at java.awt.EventQueue$3.run(Unknown Source) 
    at java.awt.EventQueue$3.run(Unknown Source) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) 
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) 
    at java.awt.EventQueue$4.run(Unknown Source) 
    at java.awt.EventQueue$4.run(Unknown Source) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) 
    at java.awt.EventQueue.dispatchEvent(Unknown Source) 
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
    at java.awt.EventDispatchThread.run(Unknown Source) 

私は8080ポートで最初チエニル同じWebサービスを使用し、それは完全に働いたが、今で証明書を使用して、それは動作しません。

私はクライアントJavaプロジェクトの.cerファイルと関係がある人は誰でも私に説明することができますか?

ありがとうございました。クライアント側では

答えて

0

が、あなたはおそらく、これらのプロパティを設定する必要があります。

  • -Djavax.net.ssl.keyStore = path_to_keystore
  • -Djavax.net.ssl.keyStorePassword = keystore_password

もちろん、キーストアには証明書(.cer)が含まれています

クライアントコードを掲載することはできますか?

+0

クライアントコードを送信できません。私は単にクラスとしてjava.rmi.Remoteをコネクションとして拡張しました。その後。 – DeathGun

+0

メインクラスから呼び出すと、オブジェクトがクラスに送信されてアクセスが検証され、Webサービスがデータを返しました。しかし、どのコードにクライアント(Eclipse)で書くべきかわからない – DeathGun

+0

設定する必要があるのは2つあります。最初は、サーバーがクライアントと通信できるように、クライアント側のtrustStoreになります。 2番目はオプションのキーストア(私の答えで言及したもの)で、これはクライアントがサーバー上で認証するために使用されます。どちらが正確に必要ですか?多分両方 ? –

関連する問題