Created
March 31, 2020 18:16
-
-
Save cipherboy/91a2f6dc4b3a9c197136a966e94975d8 to your computer and use it in GitHub Desktop.
JDK8u JSSE - Exceptions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class X509TrustManagerJavaxWrapper implements | |
javax.net.ssl.X509TrustManager { | |
private X509TrustManager theX509TrustManager; | |
X509TrustManagerJavaxWrapper(X509TrustManager obj) { | |
theX509TrustManager = obj; | |
} | |
public void checkClientTrusted( | |
java.security.cert.X509Certificate[] chain, String authType) | |
throws java.security.cert.CertificateException { | |
if (!theX509TrustManager.isClientTrusted(chain)) { | |
// New generic exception thrown here. | |
throw new java.security.cert.CertificateException( | |
"Untrusted Client Certificate Chain"); | |
} | |
} | |
public void checkServerTrusted( | |
java.security.cert.X509Certificate[] chain, String authType) | |
throws java.security.cert.CertificateException { | |
if (!theX509TrustManager.isServerTrusted(chain)) { | |
throw new java.security.cert.CertificateException( | |
"Untrusted Server Certificate Chain"); | |
} | |
} | |
public java.security.cert.X509Certificate[] getAcceptedIssuers() { | |
return theX509TrustManager.getAcceptedIssuers(); | |
} | |
} | |
final class X509TrustManagerComSunWrapper implements X509TrustManager { | |
private javax.net.ssl.X509TrustManager theX509TrustManager; | |
X509TrustManagerComSunWrapper(javax.net.ssl.X509TrustManager obj) { | |
theX509TrustManager = obj; | |
} | |
public boolean isClientTrusted( | |
java.security.cert.X509Certificate[] chain) { | |
try { | |
// Exception thrown here. | |
theX509TrustManager.checkClientTrusted(chain, "UNKNOWN"); | |
return true; | |
} catch (java.security.cert.CertificateException e) { | |
// Exception suppressed here. | |
return false; | |
} | |
} | |
public boolean isServerTrusted( | |
java.security.cert.X509Certificate[] chain) { | |
try { | |
theX509TrustManager.checkServerTrusted(chain, "UNKNOWN"); | |
return true; | |
} catch (java.security.cert.CertificateException e) { | |
return false; | |
} | |
} | |
public java.security.cert.X509Certificate[] getAcceptedIssuers() { | |
return theX509TrustManager.getAcceptedIssuers(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment