mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-30 13:12:25 -05:00
Return proper error message when certificate couldn't be verified against global key store
This commit is contained in:
parent
25147754e9
commit
43bf41332d
@ -71,11 +71,14 @@ public final class TrustManagerFactory {
|
|||||||
|
|
||||||
public void checkServerTrusted(X509Certificate[] chain, String authType)
|
public void checkServerTrusted(X509Certificate[] chain, String authType)
|
||||||
throws CertificateException {
|
throws CertificateException {
|
||||||
|
String message = null;
|
||||||
boolean foundInGlobalKeyStore = false;
|
boolean foundInGlobalKeyStore = false;
|
||||||
try {
|
try {
|
||||||
defaultTrustManager.checkServerTrusted(chain, authType);
|
defaultTrustManager.checkServerTrusted(chain, authType);
|
||||||
foundInGlobalKeyStore = true;
|
foundInGlobalKeyStore = true;
|
||||||
} catch (CertificateException e) { /* ignore */ }
|
} catch (CertificateException e) {
|
||||||
|
message = e.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
X509Certificate certificate = chain[0];
|
X509Certificate certificate = chain[0];
|
||||||
|
|
||||||
@ -86,9 +89,12 @@ public final class TrustManagerFactory {
|
|||||||
|| keyStore.isValidCertificate(certificate, mHost, mPort)) {
|
|| keyStore.isValidCertificate(certificate, mHost, mPort)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String message = (foundInGlobalKeyStore) ?
|
|
||||||
"Certificate domain name does not match " + mHost :
|
if (message == null) {
|
||||||
"Couldn't find certificate in local key store";
|
message = (foundInGlobalKeyStore) ?
|
||||||
|
"Certificate domain name does not match " + mHost :
|
||||||
|
"Couldn't find certificate in local key store";
|
||||||
|
}
|
||||||
|
|
||||||
throw new CertificateChainException(message, chain);
|
throw new CertificateChainException(message, chain);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user