0

I have spring boot project. And i have added my certificates in spring boot application class.

System.setProperty("javax.net.ssl.trustStore", "support/truststore.jks");
System.setProperty("javax.net.ssl.trustStorePassword", "xxx");  
    
System.setProperty("javax.net.ssl.keystore", "support/bravo_prod_keystore.jks");
System.setProperty("javax.net.ssl.keyStorePassword", "xxxx");

I have also called the below code

    public static void doTrustToCertificates() throws Exception {
    Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
    TrustManager[] trustAllCerts = new TrustManager[]{
            new X509TrustManager() {
                
                @Override
                public X509Certificate[] getAcceptedIssuers() {
                    // TODO Auto-generated method stub
                    return null;
                }
                
                @Override
                public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
                    // TODO Auto-generated method stub
                    
                }
                
                @Override
                public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
                    // TODO Auto-generated method stub
                }
                }
            };


    SSLContext sc = SSLContext.getInstance("SSL");
    sc.init(null, trustAllCerts, new SecureRandom());
    HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
    HostnameVerifier hv = new HostnameVerifier() {
        
        @Override
        public boolean verify(String urlHostName, SSLSession session) {
             if (!urlHostName.equalsIgnoreCase(session.getPeerHost())) {
                    System.out.println("Warning: URL host '" + urlHostName + "' is different to SSLSession host '" + session.getPeerHost() + "'.");
                }
                return true;
        }
    };
}  

I am getting in response. readHandshakeRecord; nested exception is javax.net.ssl.SSLException: readHandshakeRecord

Can anyone help me to resolve this issue.

stikkoo
  • 3
  • 1
  • 4

0 Answers0