public static ConscryptPlatform buildIfSupported() { try { // Trigger an early exception over a fatal error, prefer a RuntimeException over Error. Class.forName("org.conscrypt.Conscrypt"); if (!Conscrypt.isAvailable()) { return null; } return new ConscryptPlatform(); } catch (ClassNotFoundException e) { return null; } }
@Override public SSLContext getSSLContext() { try { return SSLContext.getInstance("TLSv1.3", getProvider()); } catch (NoSuchAlgorithmException e) { try { // Allow for Conscrypt 1.2 return SSLContext.getInstance("TLS", getProvider()); } catch (NoSuchAlgorithmException e2) { throw new IllegalStateException("No TLS provider", e); } } }
@Override public @Nullable X509TrustManager trustManager(SSLSocketFactory sslSocketFactory) { if (!Conscrypt.isConscrypt(sslSocketFactory)) { return super.trustManager(sslSocketFactory); } try { // org.conscrypt.SSLParametersImpl Object sp = readFieldOrNull(sslSocketFactory, Object.class, "sslParameters"); if (sp != null) { return readFieldOrNull(sp, X509TrustManager.class, "x509TrustManager"); } return null; } catch (Exception e) { throw new UnsupportedOperationException( "clientBuilder.sslSocketFactory(SSLSocketFactory) not supported on Conscrypt", e); } }
/** Attempt to match the host runtime to a capable Platform implementation. */ private static Platform findPlatform() { Platform android = AndroidPlatform.buildIfSupported(); if (android != null) { return android; } if (isConscryptPreferred()) { Platform conscrypt = ConscryptPlatform.buildIfSupported(); if (conscrypt != null) { return conscrypt; } } Platform jdk9 = Jdk9Platform.buildIfSupported(); if (jdk9 != null) { return jdk9; } Platform jdkWithJettyBoot = Jdk8WithJettyBootPlatform.buildIfSupported(); if (jdkWithJettyBoot != null) { return jdkWithJettyBoot; } // Probably an Oracle JDK like OpenJDK. return new Platform(); }
/** Attempt to match the host runtime to a capable Platform implementation. */ private static Platform findPlatform() { Platform android = AndroidPlatform.buildIfSupported(); if (android != null) { return android; } if (isConscryptPreferred()) { Platform conscrypt = ConscryptPlatform.buildIfSupported(); if (conscrypt != null) { return conscrypt; } } Platform jdk9 = Jdk9Platform.buildIfSupported(); if (jdk9 != null) { return jdk9; } Platform jdkWithJettyBoot = Jdk8WithJettyBootPlatform.buildIfSupported(); if (jdkWithJettyBoot != null) { return jdkWithJettyBoot; } // Probably an Oracle JDK like OpenJDK. return new Platform(); }
@Override public SSLContext getSSLContext() { try { return SSLContext.getInstance("TLSv1.3", getProvider()); } catch (NoSuchAlgorithmException e) { try { // Allow for Conscrypt 1.2 return SSLContext.getInstance("TLS", getProvider()); } catch (NoSuchAlgorithmException e2) { throw new IllegalStateException("No TLS provider", e); } } }
public static ConscryptPlatform buildIfSupported() { try { // Trigger an early exception over a fatal error, prefer a RuntimeException over Error. Class.forName("org.conscrypt.Conscrypt"); if (!Conscrypt.isAvailable()) { return null; } return new ConscryptPlatform(); } catch (ClassNotFoundException e) { return null; } }
@Override public @Nullable X509TrustManager trustManager(SSLSocketFactory sslSocketFactory) { if (!Conscrypt.isConscrypt(sslSocketFactory)) { return super.trustManager(sslSocketFactory); } try { // org.conscrypt.SSLParametersImpl Object sp = readFieldOrNull(sslSocketFactory, Object.class, "sslParameters"); if (sp != null) { return readFieldOrNull(sp, X509TrustManager.class, "x509TrustManager"); } return null; } catch (Exception e) { throw new UnsupportedOperationException( "clientBuilder.sslSocketFactory(SSLSocketFactory) not supported on Conscrypt", e); } }
/** Attempt to match the host runtime to a capable Platform implementation. */ private static Platform findPlatform() { Platform android = AndroidPlatform.buildIfSupported(); if (android != null) { return android; } if (isConscryptPreferred()) { Platform conscrypt = ConscryptPlatform.buildIfSupported(); if (conscrypt != null) { return conscrypt; } } Platform jdk9 = Jdk9Platform.buildIfSupported(); if (jdk9 != null) { return jdk9; } Platform jdkWithJettyBoot = JdkWithJettyBootPlatform.buildIfSupported(); if (jdkWithJettyBoot != null) { return jdkWithJettyBoot; } // Probably an Oracle JDK like OpenJDK. return new Platform(); }
@Override public SSLContext getSSLContext() { try { return SSLContext.getInstance("TLSv1.3", getProvider()); } catch (NoSuchAlgorithmException e) { try { // Allow for Conscrypt 1.2 return SSLContext.getInstance("TLS", getProvider()); } catch (NoSuchAlgorithmException e2) { throw new IllegalStateException("No TLS provider", e); } } }
public static ConscryptPlatform buildIfSupported() { try { // Trigger an early exception over a fatal error, prefer a RuntimeException over Error. Class.forName("org.conscrypt.Conscrypt"); if (!Conscrypt.isAvailable()) { return null; } return new ConscryptPlatform(); } catch (ClassNotFoundException e) { return null; } }
@Override public @Nullable X509TrustManager trustManager(SSLSocketFactory sslSocketFactory) { if (!Conscrypt.isConscrypt(sslSocketFactory)) { return super.trustManager(sslSocketFactory); } try { // org.conscrypt.SSLParametersImpl Object sp = readFieldOrNull(sslSocketFactory, Object.class, "sslParameters"); if (sp != null) { return readFieldOrNull(sp, X509TrustManager.class, "x509TrustManager"); } return null; } catch (Exception e) { throw new UnsupportedOperationException( "clientBuilder.sslSocketFactory(SSLSocketFactory) not supported on Conscrypt", e); } }