- protected SSLContext createSSLContext(Parameters p) {
- try (FileInputStream in = new FileInputStream(p.keyStoreFileName)) {
- System.setProperty("jsse.enableSNIExtension", "false");
- System.setProperty("javax.net.ssl.trustStore", p.trustStoreFileName);
- System.setProperty("javax.net.ssl.trustStorePassword", p.trustStorePassword);
-
- HttpsURLConnection.setDefaultHostnameVerifier((string, ssls) -> true);
-
- KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
- KeyStore ks = KeyStore.getInstance("PKCS12");
- char[] pwd = p.keyStorePassword.toCharArray();
- ks.load(in, pwd);
- kmf.init(ks, pwd);
-
- SSLContext ctx = SSLContext.getInstance("TLS");
- ctx.init(kmf.getKeyManagers(), null, null);
- return ctx;
- } catch (Exception e) {
- log.error("Error creating SSLContext: {}", e.getMessage(), e);
- }
- return null;
- }
-