private static SSLSocketFactory systemDefaultSslSocketFactory(X509TrustManager trustManager) { KeyManager[] defaultKeyManager; try { defaultKeyManager = getDefaultKeyManager(); } catch (Exception e) { throw new IllegalStateException("Unable to get default key manager", e); } try { SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(defaultKeyManager, new TrustManager[] {trustManager}, null); return sslContext.getSocketFactory(); } catch (GeneralSecurityException e) { // The system has no TLS. Just give up. throw new AssertionError(e); } }
private static SSLSocketFactory systemDefaultSslSocketFactory(X509TrustManager trustManager) { KeyManager[] defaultKeyManager; try { defaultKeyManager = getDefaultKeyManager(); } catch (Exception e) { throw new IllegalStateException("Unable to get default key manager", e); } try { SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(defaultKeyManager, new TrustManager[] {trustManager}, null); return sslContext.getSocketFactory(); } catch (GeneralSecurityException e) { // The system has no TLS. Just give up. throw new AssertionError(e); } }