Вызов Soap Api в java с аутентификацией SSL-сертификата - PullRequest
0 голосов
/ 27 февраля 2019

Я пытаюсь вызвать soap API в JAVA с SSL (я пробовал в soapui, он работает нормально), то же самое, что мне нужно сделать в java.Может ли кто-нибудь помочь мне добиться этого в java

System.setProperty("javax.net.ssl.trustStore", "C:\\java\\java6u45\\jre\\lib\\security\\x");
System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
System.setProperty("javax.net.ssl.trustStoreType", "JKS");

System.setProperty("javax.net.ssl.keyStore", "C:\\Users\\user\\Desktop\\SoapUI (1)\\SoapUI\\x.p12");
System.setProperty("javax.net.ssl.keyStorePassword", "passX!");
System.setProperty("javax.net.ssl.keyStoreType", "PKCS12");
System.setProperty("https.protocols", "TLSv1");



URL u = null;
try {
    u = new URL("https://x1/x2WS/x3?wsdl");
} catch(Exception ex) {
    ex.printStackTrace();
}
JobInput2Service service = new JobInput2Service(u);
JobInput2 job = service.getJobInput2Port();
try {
    HelloRequestParm parm = new HelloRequestParm();
    parm.setMessage("value");
    HelloResponseData res = job.sayHello(parm);
    System.out.print("\n res: "+res.getMessage());
} catch (Exception ex) {
    ex.printStackTrace();
} 

Я получаю: javax.net.ssl.SSLHandshakeException: получено фатальное предупреждение: handshake_failure

 sayHello has thrown exception, unwinding now
    org.apache.cxf.interceptor.Fault: Could not send Message.
        at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
9)
        at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:133)
        at com.sun.proxy.$Proxy31.sayHello(Unknown Source)
        at program.Wsdl2Java6_32bit.main(Wsdl2Java6_32bit.java:85)
    Caused by: javax.net.ssl.SSLHandshakeException: SSLHandshakeException invoking https:.....JobInput2: Received fatal alert: handshake_failure
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at o    at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
        ... 9 more
    Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
        at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
        at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:136)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1822)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1004)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:820)
        at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:75))
        at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:641)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1218)
        at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:318)
        at org.apache.cxf.transport.http.URLConnectionHTTPConduit$URLConnectionWrappedOutputStream.getResponseCode(URLConnectionHTTPConduit.java:248)
        at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1517)
        at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1490)
        at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1309)
        ... 12 more
    Wed Feb 27 17:23:56 CET 2019javax.xml.ws.WebServiceException: Could not send Message.

На серере я получаю:

SSL Library Error: error:140890C7:SSL routines:ssl3_get_client_certificate:peer did not return a certificate -- No CAs known to server for verification?
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...