无法使用HTTPS连接到外部服务器

时间:2019-01-03 12:19:16

标签: java xml ssl soap

外部公司为我提供了PFX证书文件,以便我可以连接到他们的服务器并访问他们的API。我使用以下命令将此文件转换为JKS:

keytool -importkeystore -srckeystore foo.pfx -srcstoretype pkcs12 -destkeystore foo.jks -deststoretype JKS

然后,我看了这个gist,它显示了如何创建一个简单的Java SOAP客户端来发送SOAP / XML有效负载。我已将其更改为指向我的新JKS,并且还正确设置了密码。我还更改了URL以使其指向明显。

但是,连接时我遇到了这个问题:

Exception in thread "main" javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: java.security.SignatureException: Signature does not match.
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
    at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1946)
    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:316)
    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:310)
    at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1639)
    at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:223)
    at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1037)
    at sun.security.ssl.Handshaker.process_record(Handshaker.java:965)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1064)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1367)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1395)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1379)
    at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1334)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1309)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:259)
    at org.ofsted.SSLtest.run(SSLtest.java:216)
    at org.ofsted.SSLtest.main(SSLtest.java:237)
Caused by: java.security.cert.CertificateException: java.security.SignatureException: Signature does not match.
    at org.ofsted.SSLtest$1.checkServerTrusted(SSLtest.java:146)
    at sun.security.ssl.AbstractTrustManagerWrapper.checkServerTrusted(SSLContextImpl.java:1091)
    at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1621)
    ... 14 more
Caused by: java.security.SignatureException: Signature does not match.
    at sun.security.x509.X509CertImpl.verify(X509CertImpl.java:449)
    at sun.security.x509.X509CertImpl.verify(X509CertImpl.java:392)
    at org.ofsted.SSLtest$1.checkServerTrusted(SSLtest.java:143)
    ... 16 more

我已经阅读了有关以下Java CertificationException错误的其他文章:

javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: java.security.SignatureException: 
Signature does not match 

我查看了有关此错误的其他帖子,他们谈论信任外部公司发送给我的证书。但是我很困惑。 PFX文件是否经过认证?我以为证书应该以.crt扩展名?没有?任何建议将非常有帮助。谢谢。

0 个答案:

没有答案
相关问题