summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2016-02-02 15:22:06 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2016-02-02 15:22:06 +0000
commit0cb30dd4fb486d9add3b1f8ff7a2b0a750cfcb28 (patch)
tree0f9a0ff5e0865ff983c6c9c62dbc08db240d9b04
parent8a99e01bd455829323c810a53b8ca004943372ba (diff)
parent1a795a18fadcfec9941bef9b241fdcc77f92584e (diff)
downloadapache-http-0cb30dd4fb486d9add3b1f8ff7a2b0a750cfcb28.tar.gz
Merge "Unhook a bit from Conscrypt's implementation"
-rw-r--r--android/src/android/net/http/CertificateChainValidator.java33
1 files changed, 14 insertions, 19 deletions
diff --git a/android/src/android/net/http/CertificateChainValidator.java b/android/src/android/net/http/CertificateChainValidator.java
index 8f1a9e3..96bf169 100644
--- a/android/src/android/net/http/CertificateChainValidator.java
+++ b/android/src/android/net/http/CertificateChainValidator.java
@@ -228,26 +228,21 @@ public class CertificateChainValidator {
try {
X509TrustManager x509TrustManager = SSLParametersImpl.getDefaultX509TrustManager();
- if (x509TrustManager instanceof TrustManagerImpl) {
- TrustManagerImpl trustManager = (TrustManagerImpl) x509TrustManager;
- trustManager.checkServerTrusted(chain, authType, domain);
- } else {
- // Use duck-typing to try and call the hostname aware checkServerTrusted if
- // available.
- try {
- Method method = x509TrustManager.getClass().getMethod("checkServerTrusted",
- X509Certificate[].class,
- String.class,
- String.class);
- method.invoke(x509TrustManager, chain, authType, domain);
- } catch (NoSuchMethodException | IllegalAccessException e) {
- x509TrustManager.checkServerTrusted(chain, authType);
- } catch (InvocationTargetException e) {
- if (e.getCause() instanceof CertificateException) {
- throw (CertificateException) e.getCause();
- }
- throw new RuntimeException(e.getCause());
+ // Use duck-typing to try and call the hostname aware checkServerTrusted if
+ // available.
+ try {
+ Method method = x509TrustManager.getClass().getMethod("checkServerTrusted",
+ X509Certificate[].class,
+ String.class,
+ String.class);
+ method.invoke(x509TrustManager, chain, authType, domain);
+ } catch (NoSuchMethodException | IllegalAccessException e) {
+ x509TrustManager.checkServerTrusted(chain, authType);
+ } catch (InvocationTargetException e) {
+ if (e.getCause() instanceof CertificateException) {
+ throw (CertificateException) e.getCause();
}
+ throw new RuntimeException(e.getCause());
}
return null; // No errors.
} catch (GeneralSecurityException e) {