mirror of
https://github.com/moparisthebest/k-9
synced 2025-02-17 07:30:16 -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 static final long serialVersionUID = 1103894512106650107L;
|
||||||
private X509Certificate[] mCertChain;
|
private X509Certificate[] mCertChain;
|
||||||
|
|
||||||
public CertificateChainException(String msg, X509Certificate[] chain) {
|
public CertificateChainException(String msg, X509Certificate[] chain, Throwable cause) {
|
||||||
super(msg);
|
super(msg, cause);
|
||||||
setCertChain(chain);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CertificateChainException(CertificateException ce,
|
|
||||||
X509Certificate[] chain) {
|
|
||||||
super.initCause(ce);
|
|
||||||
setCertChain(chain);
|
setCertChain(chain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +63,8 @@ public final class TrustManagerFactory {
|
|||||||
String message = null;
|
String message = null;
|
||||||
X509Certificate certificate = chain[0];
|
X509Certificate certificate = chain[0];
|
||||||
|
|
||||||
|
Throwable cause = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
defaultTrustManager.checkServerTrusted(chain, authType);
|
defaultTrustManager.checkServerTrusted(chain, authType);
|
||||||
new StrictHostnameVerifier().verify(mHost, certificate);
|
new StrictHostnameVerifier().verify(mHost, certificate);
|
||||||
@ -70,15 +72,17 @@ public final class TrustManagerFactory {
|
|||||||
} catch (CertificateException e) {
|
} catch (CertificateException e) {
|
||||||
// cert. chain can't be validated
|
// cert. chain can't be validated
|
||||||
message = e.getMessage();
|
message = e.getMessage();
|
||||||
|
cause = e;
|
||||||
} catch (SSLException e) {
|
} catch (SSLException e) {
|
||||||
// host name doesn't match certificate
|
// host name doesn't match certificate
|
||||||
message = e.getMessage();
|
message = e.getMessage();
|
||||||
|
cause = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the local key store if we couldn't verify the certificate using the global
|
// 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
|
// key store or if the host name doesn't match the certificate name
|
||||||
if (!keyStore.isValidCertificate(certificate, mHost, mPort)) {
|
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