1

I need to call a restapi which requires SSL certificate which i have installed on WebSphere. Now when i hit the API it gives me an error of 401 not authenticated. Using SSL Certificate i am able to call using PostMan By Attaching Client Certificate and attaching passphrase and private key reference

SSLContext sslctx = SSLContext.getInstance("TLS");

            TrustManager[ ] trustcertmgr = getCerticateTrustManager();
            sslctx.init(null,                // key manager
                         trustcertmgr,           // trust manager
                         new SecureRandom()); // random number generator

            HttpsURLConnection.setDefaultSSLSocketFactory(sslctx.getSocketFactory());

            url = new URL(clienturl);



            HttpsURLConnection con = (HttpsURLConnection)url.openConnection();
            con.setHostnameVerifier(new HostnameVerifier() {
            public boolean verify(String host, SSLSession sess)
            {

                return false;
            }});
            System.err.println("Connection Created with URL:" + clienturl);
Sumit Arora
  • 101
  • 1
  • 1
  • 5
  • Possible duplicate of [Java HTTPS client certificate authentication](https://stackoverflow.com/questions/1666052/java-https-client-certificate-authentication) – Roman Vottner Apr 25 '19 at 12:42

0 Answers0