title: javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated error
body: <p>This is a question regarding an exception that is occurring in my code which makes a call to an https server. </p>
  
  <pre><code>javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
  </code></pre>
  
  <p>It internally uses an instance of <code>CloseableHttpClient</code> to execute the PUT call.</p>
  
  <p>Also, this code is a functional test that would be running on a remote machine as a CI job. I have seen some solutions with the SSL certificate error that mention how we can disable the SSL certificate validation in Java or add the certificate in the local JVM, one of them being here -  </p>
  
  <p><a href="https://stackoverflow.com/questions/23754081/peer-not-authenticated-ssl-certificate-error-usng-defaulthttpclient">&#39;peer not authenticated&#39; SSL certificate error usng DefaultHttpClient</a></p>
  
  <p>Unfortunately, it doesn't seem to be working as this is a remote machine and we cannot import certificates into that machine. </p>
  
  <pre><code>String endPoint = "https://" + hostName + ":" + port + "/v1/service/data/put";
  </code></pre>
  
  <p>endPoint is set in the code that is called from a jar. So, there is no scope that we'd be able to change it either. </p>
  
  <p>If I am running the code that makes a PUT call to the endPoint from a standalone class (through the main method), it seems to be running fine, returning a 200/OK. Currently, the exception occurs if it is being run as a TestNG class from the .xml file.</p>
  
  <p>The code added as a Github gist is <a href="https://gist.github.com/sarankumarv/b05cba4d86080e84eed693bd6789f25e" rel="nofollow noreferrer">here</a>.</p>
  
  <p>Let me know if you need more details.</p>