|
69 | 69 | import javax.net.ssl.TrustManagerFactory; |
70 | 70 | import lombok.extern.slf4j.Slf4j; |
71 | 71 | import org.apache.commons.lang3.StringUtils; |
72 | | -import org.apache.pulsar.common.classification.InterfaceAudience; |
73 | 72 | import org.apache.pulsar.common.tls.TlsHostnameVerifier; |
74 | 73 |
|
75 | 74 | /** |
@@ -162,10 +161,11 @@ private static Provider loadConscryptProvider() { |
162 | 161 | // |
163 | 162 | // more details of Conscrypt's hostname verification: |
164 | 163 | // https://github.com/google/conscrypt/blob/master/IMPLEMENTATION_NOTES.md#hostname-verification |
165 | | - // there's a bug in Conscrypt while setting a custom HostnameVerifier, |
166 | | - // https://github.com/google/conscrypt/issues/1015 and therefore this solution alone |
167 | | - // isn't sufficient to configure Conscrypt's hostname verifier. The method processConscryptTrustManager |
168 | | - // contains the workaround. |
| 164 | + // |
| 165 | + // Setting the default is sufficient on its own since Conscrypt 2.6.0: TrustManagerImpl used to ignore |
| 166 | + // the default verifier (https://github.com/google/conscrypt/issues/1015), which forced Pulsar to copy it |
| 167 | + // onto every TrustManager instance, but https://github.com/google/conscrypt/pull/1060 made it fall back |
| 168 | + // to the default, so that workaround has been removed. |
169 | 169 | try { |
170 | 170 | HostnameVerifier hostnameVerifier = new TlsHostnameVerifier(); |
171 | 171 | Object wrappedHostnameVerifier = conscryptClazz |
@@ -397,54 +397,10 @@ private static TrustManager[] setupTrustCerts(KeyStoreHolder ksh, boolean allowI |
397 | 397 | } |
398 | 398 |
|
399 | 399 | trustManagers = tmf.getTrustManagers(); |
400 | | - |
401 | | - for (TrustManager trustManager : trustManagers) { |
402 | | - processConscryptTrustManager(trustManager); |
403 | | - } |
404 | 400 | } |
405 | 401 | return trustManagers; |
406 | 402 | } |
407 | 403 |
|
408 | | - /*** |
409 | | - * Conscrypt TrustManager instances will be configured to use the Pulsar {@link TlsHostnameVerifier} |
410 | | - * class. |
411 | | - * This method is used as a workaround for https://github.com/google/conscrypt/issues/1015 |
412 | | - * when Conscrypt / OpenSSL is used as the TLS security provider. |
413 | | - * |
414 | | - * @param trustManagers the array of TrustManager instances to process. |
415 | | - * @return same instance passed as parameter |
416 | | - */ |
417 | | - @InterfaceAudience.Private |
418 | | - public static TrustManager[] processConscryptTrustManagers(TrustManager[] trustManagers) { |
419 | | - for (TrustManager trustManager : trustManagers) { |
420 | | - processConscryptTrustManager(trustManager); |
421 | | - } |
422 | | - return trustManagers; |
423 | | - } |
424 | | - |
425 | | - // workaround https://github.com/google/conscrypt/issues/1015 |
426 | | - private static void processConscryptTrustManager(TrustManager trustManager) { |
427 | | - if (trustManager.getClass().getName().equals("org.conscrypt.TrustManagerImpl")) { |
428 | | - try { |
429 | | - Class<?> conscryptClazz = Class.forName("org.conscrypt.Conscrypt"); |
430 | | - Object hostnameVerifier = conscryptClazz.getMethod("getHostnameVerifier", |
431 | | - new Class[]{TrustManager.class}).invoke(null, trustManager); |
432 | | - if (hostnameVerifier == null) { |
433 | | - Object defaultHostnameVerifier = conscryptClazz.getMethod("getDefaultHostnameVerifier", |
434 | | - new Class[]{TrustManager.class}).invoke(null, trustManager); |
435 | | - if (defaultHostnameVerifier != null) { |
436 | | - conscryptClazz.getMethod("setHostnameVerifier", new Class[]{ |
437 | | - TrustManager.class, |
438 | | - Class.forName("org.conscrypt.ConscryptHostnameVerifier") |
439 | | - }).invoke(null, trustManager, defaultHostnameVerifier); |
440 | | - } |
441 | | - } |
442 | | - } catch (ReflectiveOperationException e) { |
443 | | - log.warn("Unable to set hostname verifier for Conscrypt TrustManager implementation", e); |
444 | | - } |
445 | | - } |
446 | | - } |
447 | | - |
448 | 404 | public static X509Certificate[] loadCertificatesFromPemFile(String certFilePath) throws KeyManagementException { |
449 | 405 | X509Certificate[] certificates = null; |
450 | 406 |
|
|