Skip to content

Commit

Permalink
Use JDK default security provider when Conscrypt isn't available (#12938
Browse files Browse the repository at this point in the history
)

- fixes issue with ARM64 platform where Conscrypt isn't available
  • Loading branch information
lhotari committed Nov 25, 2021
1 parent 959430c commit 4f2d52e
Showing 1 changed file with 10 additions and 1 deletion.
Expand Up @@ -115,6 +115,16 @@ public static Provider getProvider() {
}

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();
Expand Down Expand Up @@ -142,7 +152,6 @@ private static Provider loadConscryptProvider() {
// 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);
Expand Down

0 comments on commit 4f2d52e

Please sign in to comment.