[英]javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated in netbeans
I am using HttpClient-4.0.3 and already added certificate on server. 我正在使用HttpClient-4.0.3,并且已经在服务器上添加了证书。 The command is as below :
命令如下:
keytool -import -file "C:\Users\apex\Downloads\RootCABangladesh2016.cer" -keystore "C:\Program Files\Java\jdk1.8.0_131\jre\lib\security\cacerts" -alias "sds certificate"
But still I am getting below error. 但是我仍然低于错误。
I have read existing issue saying to add TrustManager (X509TrustManager) but as per my thinking this is not solution. 我已经阅读了存在的问题,说要添加TrustManager(X509TrustManager),但是按照我的想法,这不是解决方案。
The exception is as follows : 异常如下:
javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
at sun.security.ssl.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:431)
at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:128)
at org.apache.http.conn.ssl.SSLSocketFactory.createSocket(SSLSocketFactory.java:399)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:143)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:108)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:415)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:554)
at jsonParser.JSONParser.makeHttpRequest(JSONParser.java:54)
at powersms.SendSms.sendSms(SendSms.java:44)
at powersms.SendSms.run(SendSms.java:32)
I have tried this solution . 我已经尝试过这种解决方案。 But this is not working for me .
但这对我没有用。
I have checked the expire date by this command. 我已经通过此命令检查了过期日期。
keytool -list -v -alias "sds certificate" -keystore "C:\Program Files\Java\jdk1.8.0_131\jre\lib\security\cacerts" -storepass "changeit" | grep "Valid from:"
But this shows me : 但这告诉我:
Valid from: Wed Dec 21 16:43:56 BDT 2016 until: Mon Dec 21 16:43:56 BDT 2026
I have added jvm parameters . 我添加了jvm参数。
-Djavax.net.debug=ssl:handshake
Then I go this output : 然后我去这个输出:
javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
at sun.security.ssl.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:431)
at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:128)
at org.apache.http.conn.ssl.SSLSocketFactory.createSocket(SSLSocketFactory.java:399)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:143)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:108)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:415)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:554)
at jsonParser.JSONParser.makeHttpRequest(JSONParser.java:54)
at powersms.SendSms.sendSms(SendSms.java:44)
at powersms.SendSms.run(SendSms.java:32)
%% Invalidated: [Session-1, TLS_RSA_WITH_AES_128_CBC_SHA]
Thread-0, SEND TLSv1 ALERT: fatal, description = certificate_unknown
Thread-0, WRITE: TLSv1 Alert, length = 2
Thread-0, called closeSocket()
Thread-0, handling exception: 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
Thread-0, IOException in getSession(): 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
Buffer Error Error converting result java.lang.NullPointerException
JSON ParserError parsing data org.json.JSONException: A JSONObject text must begin with '{' at character 0
Json is null
This has been an issue with HttpClient
for a while when you try to connect to a secured(ie https) URL. 当您尝试连接到安全(即https)URL时,
HttpClient
一直存在此问题。 There's this class EasySSLProtocolSocketFactory
in HttpClient
though, which lets you create sockets
that accept self-signed certificates. 但是,
HttpClient
有此类EasySSLProtocolSocketFactory
,它使您可以创建接受自签名证书的sockets
。 You can try using that as described in the documentation- EasySSLProtocolSocketFactory 您可以按照文档EasySSLProtocolSocketFactory中的描述尝试使用它
Not sure if it will solve your problem or not, and it's not very much encouraged to use in production. 不知道它是否可以解决您的问题,也不鼓励在生产中使用它。 But you can definitely give it a try to see how it comes up!
但是您绝对可以尝试一下,看看它是怎么出现的!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.