mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -05:00
chain the exception
This commit is contained in:
parent
7945aab8a7
commit
d980e49fd1
@ -13,14 +13,8 @@ public class CertificateChainException extends CertificateException {
|
||||
private static final long serialVersionUID = 1103894512106650107L;
|
||||
private X509Certificate[] mCertChain;
|
||||
|
||||
public CertificateChainException(String msg, X509Certificate[] chain) {
|
||||
super(msg);
|
||||
setCertChain(chain);
|
||||
}
|
||||
|
||||
public CertificateChainException(CertificateException ce,
|
||||
X509Certificate[] chain) {
|
||||
super.initCause(ce);
|
||||
public CertificateChainException(String msg, X509Certificate[] chain, Throwable cause) {
|
||||
super(msg, cause);
|
||||
setCertChain(chain);
|
||||
}
|
||||
|
||||
|
@ -63,6 +63,8 @@ public final class TrustManagerFactory {
|
||||
String message = null;
|
||||
X509Certificate certificate = chain[0];
|
||||
|
||||
Throwable cause = null;
|
||||
|
||||
try {
|
||||
defaultTrustManager.checkServerTrusted(chain, authType);
|
||||
new StrictHostnameVerifier().verify(mHost, certificate);
|
||||
@ -70,15 +72,17 @@ public final class TrustManagerFactory {
|
||||
} catch (CertificateException e) {
|
||||
// cert. chain can't be validated
|
||||
message = e.getMessage();
|
||||
cause = e;
|
||||
} catch (SSLException e) {
|
||||
// host name doesn't match certificate
|
||||
message = e.getMessage();
|
||||
cause = e;
|
||||
}
|
||||
|
||||
// Check the local key store if we couldn't verify the certificate using the global
|
||||
// key store or if the host name doesn't match the certificate name
|
||||
if (!keyStore.isValidCertificate(certificate, mHost, mPort)) {
|
||||
throw new CertificateChainException(message, chain);
|
||||
throw new CertificateChainException(message, chain, cause);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user