• Register
0 votes

Problem :

Experiencing bellow error
javax.net.ssl.sslpeerunverifiedexception: peer not authenticated
6 5 3
6,930 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

You are experiencing this error because the server does not have a valid SSL certificate. So we must tell the client to use a different TrustManager. 

Bellow is the sample code:

SSLContext ctx = SSLContext.getInstance("TLS");
X509TrustManager tm = new X509TrustManager() {

public void checkClientTrusted(X509Certificate[] xcs, String string) throws CertificateException {

public void checkServerTrusted(X509Certificate[] xcs, String string) throws CertificateException {

public X509Certificate[] getAcceptedIssuers() {
return null;
ctx.init(null, new TrustManager[]{tm}, null);
SSLSocketFactory ssf = new SSLSocketFactory(ctx,SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
ClientConnectionManager ccm = base.getConnectionManager();
SchemeRegistry sr = ccm.getSchemeRegistry();
sr.register(new Scheme("https", 443, ssf));

client = new DefaultHttpClient(ccm, base.getParams());
9 7 4
38,600 points

Related questions

0 votes
1 answer 3 views
Problem: Please help me to solve it out : javax net ssl sslhandshakeexception received fatal alert handshake_failure
asked Apr 7 rakib1 51.5k points
0 votes
0 answers 1 view
1 view
Problem: What are my options for resolving this problem? javax.net.ssl.sslhandshakeexception: received fatal alert: handshake_failure
asked Apr 7 rakib1 51.5k points
0 votes
1 answer 13 views
Problem: What does it mean? How to prevent it?
asked Feb 17 TeamScript 13.5k points
0 votes
1 answer 454 views
Problem : I am trying to call an SSL protected web service running on JDK7 based client, but getting bellow error javax.net.ssl.sslexception received fatal alert unexpected_message
asked Nov 5, 2019 peterlaw 6.9k points
0 votes
2 answers 458 views
Problem : Has anyone faced this error before? I am new to SSL javax.net.ssl.sslexception: received fatal alert: protocol_version
asked Nov 2, 2019 peterlaw 6.9k points
0 votes
3 answers 278 views
Problem : I am trying to setup a SSL Socket connection. But i am getting below error javax.net.ssl.sslhandshakeexception received fatal alert bad_certificate
asked Oct 23, 2019 peterlaw 6.9k points
0 votes
1 answer 623 views
Problem : I have a java complied package and it is sopposed to communicate with https server on net. But when i try running the compilation gives the following exception: javax.net.ssl.sslexception: unrecognized ssl message, plaintext connection?
asked Oct 23, 2019 peterlaw 6.9k points
0 votes
1 answer 67 views
Problem: I've install Python 3.4 and Python 3.6 on my local machine successfully, but am unable to install packages with pip3. When I execute pip3 install <package>, I get the following SSL related error: pip is configured with locations that require TLS/SSL, ... matching distribution found for <package> How can I fix my Python3.x install so that I can install packages with pip install <package>?
asked Jan 9 Mashhoodch 13k points
1 vote
1 answer 419 views
Problem : I am beginner to Python. Currently if I try to use the request module to have the urls text then I often face below Error: Traceback (most recent call last):  File "/usr/local/lib/python3.6/site-packages/requests-2.18.1-py3.5.egg/requests/adapters.py" ... to get the url's text to parse it. Please find below my line of code for your reference: mytext = requests.get(detail_path).mytext
asked May 2, 2020 stewart 4k points