Use JDK default security provider when Conscrypt isn't available
fixes issue with ARM64 platform where Conscrypt isn't available
@@ -115,6 +115,16 @@ public class SecurityUtility {
}
private static Provider loadConscryptProvider() {
+ Class<?> conscryptClazz;
+
+ try {
+ conscryptClazz = Class.forName("org.conscrypt.Conscrypt");
+ conscryptClazz.getMethod("checkAvailability").invoke(null);
+ } catch (Throwable e) {
+ log.warn("Conscrypt isn't available. Using JDK default security provider.", e);
+ return null;
+ }
+
Provider provider;
try {
provider = (Provider) Class.forName(CONSCRYPT_PROVIDER_CLASS).getDeclaredConstructor().newInstance();
@@ -142,7 +152,6 @@ public class SecurityUtility {
// contains the workaround.
try {
HostnameVerifier hostnameVerifier = new TlsHostnameVerifier();
- Class<?> conscryptClazz = Class.forName("org.conscrypt.Conscrypt");
Object wrappedHostnameVerifier = conscryptClazz
.getMethod("wrapHostnameVerifier",
new Class[]{HostnameVerifier.class}).invoke(null, hostnameVerifier);
