+
+ public static SSLSocketFactory getSSLSocketFactory() {
+ SSLSocketFactory factory = null;
+ try {
+ CertificateManager cm = JettyServer.getCertificateManager();
+ String truststore = cm.getTrustStoreFile();
+ KeyStore ts = KeyStore.getInstance(cm.getTrustStoreType());
+ try (InputStream in = new FileInputStream(truststore)) {
+ ts.load(in, cm.getTrustStorePassword().toCharArray());
+ }
+ TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+ tmf.init(ts);
+ TrustManager[] tm = tmf.getTrustManagers();
+ SSLContext sslContext = SSLContext.getInstance("TLS");
+ sslContext.init(null, tm, null);
+ factory = sslContext.getSocketFactory();
+ } catch (Exception e) {
+ logger.error("Exception thrown trying to get SSLSocketFactory: ", e);
+ }
+ return factory;
+ }