Reputation: 179
I am using httpclient 4.5.2 to call proxy server.
HttpHost proxy = new HttpHost(proxyHost, proxyPort, https);
HttpHost target = new HttpHost(ip, 443, "https");
HttpPost httppost = new HttpPost(url);
CloseableHttpResponse response = httpclient.execute(target, httppost );
Below is the error i get:-
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
at sun.security.ssl.InputRecord.handleUnknownRecord(InputRecord.java:671)
at sun.security.ssl.InputRecord.read(InputRecord.java:504)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:927)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:394)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:353)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:141)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:388)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:117)
May I know this error is related to cert problem? Because I already add the cert to truststore.
Upvotes: 1
Views: 1313
Reputation: 123260
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
May I know this error is related to cert problem? Because I already add the cert to truststore.
This is not a problem of a certificate. The server you access does not do a proper TLS handshake.
I am using httpclient 4.5.2 to call proxy server.
HTTPS over a HTTP proxy server starts with a plain text HTTP CONNECT request which then established a tunnel. Only after this tunnel is established the TLS handshake is done with the original target server.
Upvotes: 1