mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 11:42:16 -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)
|
||||
throws CertificateException {
|
||||
String message = null;
|
||||
boolean foundInGlobalKeyStore = false;
|
||||
try {
|
||||
defaultTrustManager.checkServerTrusted(chain, authType);
|
||||
foundInGlobalKeyStore = true;
|
||||
} catch (CertificateException e) { /* ignore */ }
|
||||
} catch (CertificateException e) {
|
||||
message = e.getMessage();
|
||||
}
|
||||
|
||||
X509Certificate certificate = chain[0];
|
||||
|
||||
@ -86,9 +89,12 @@ public final class TrustManagerFactory {
|
||||
|| keyStore.isValidCertificate(certificate, mHost, mPort)) {
|
||||
return;
|
||||
}
|
||||
String message = (foundInGlobalKeyStore) ?
|
||||
"Certificate domain name does not match " + mHost :
|
||||
"Couldn't find certificate in local key store";
|
||||
|
||||
if (message == null) {
|
||||
message = (foundInGlobalKeyStore) ?
|
||||
"Certificate domain name does not match " + mHost :
|
||||
"Couldn't find certificate in local key store";
|
||||
}
|
||||
|
||||
throw new CertificateChainException(message, chain);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user