1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

Merge pull request #13 from k9mail/art/update-certificates-in-tests

Update certificates in tests
This commit is contained in:
cketti 2014-11-12 16:30:53 +01:00
commit 9e6fc7c7d1
3 changed files with 84 additions and 74 deletions

View File

@ -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);
} }

View File

@ -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);
} }
} }

View File

@ -96,69 +96,81 @@ public class TrustManagerFactoryTest extends AndroidTestCase {
+ "Dcf5/G8bZe2DnavBQfML1wI5d7NUWE8CWb95SsIvFXI0qZE0oIR+axBVl9u97uaO\n" + "Dcf5/G8bZe2DnavBQfML1wI5d7NUWE8CWb95SsIvFXI0qZE0oIR+axBVl9u97uaO\n"
+ "-----END CERTIFICATE-----\n"; + "-----END CERTIFICATE-----\n";
private static final String STARFIELD_CERT = private static final String LINUX_COM_FIRST_PARENT_CERT =
"-----BEGIN CERTIFICATE-----\n" + "-----BEGIN CERTIFICATE-----\n" +
"MIIFBzCCA++gAwIBAgICAgEwDQYJKoZIhvcNAQEFBQAwaDELMAkGA1UEBhMCVVMx\n" + "MIIGNDCCBBygAwIBAgIBGzANBgkqhkiG9w0BAQsFADB9MQswCQYDVQQGEwJJTDEW\n" +
"JTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAsT\n" + "MBQGA1UEChMNU3RhcnRDb20gTHRkLjErMCkGA1UECxMiU2VjdXJlIERpZ2l0YWwg\n" +
"KVN0YXJmaWVsZCBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2\n" + "Q2VydGlmaWNhdGUgU2lnbmluZzEpMCcGA1UEAxMgU3RhcnRDb20gQ2VydGlmaWNh\n" +
"MTExNjAxMTU0MFoXDTI2MTExNjAxMTU0MFowgdwxCzAJBgNVBAYTAlVTMRAwDgYD\n" + "dGlvbiBBdXRob3JpdHkwHhcNMDcxMDI0MjA1NzA5WhcNMTcxMDI0MjA1NzA5WjCB\n" +
"VQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFy\n" + "jDELMAkGA1UEBhMCSUwxFjAUBgNVBAoTDVN0YXJ0Q29tIEx0ZC4xKzApBgNVBAsT\n" +
"ZmllbGQgVGVjaG5vbG9naWVzLCBJbmMuMTkwNwYDVQQLEzBodHRwOi8vY2VydGlm\n" + "IlNlY3VyZSBEaWdpdGFsIENlcnRpZmljYXRlIFNpZ25pbmcxODA2BgNVB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oqpdHhp2nWBfLlOnTNqIZNJzOH37OJE6Olk45LNFJtSrqIAZyCCfM6bQgoQvZuIa\n" +
"xs9SIp+63ZMk9TxEaQj/KteaOyfaPXI9778U7JElMTz3Bls62mslV2I1C/A73Zyq\n" +
"JZWQZ8NU4ds=\n" +
"-----END CERTIFICATE-----\n"; "-----END CERTIFICATE-----\n";
private static final String LINUX_COM_CERT = private static final String LINUX_COM_CERT =
"-----BEGIN CERTIFICATE-----\n" + "-----BEGIN CERTIFICATE-----\n" +
"MIIFfDCCBGSgAwIBAgIHJ7DOOMo+MDANBgkqhkiG9w0BAQUFADCB3DELMAkGA1UE\n" + "MIIGhjCCBW6gAwIBAgIDAmiWMA0GCSqGSIb3DQEBCwUAMIGMMQswCQYDVQQGEwJJ\n" +
"BhMCVVMxEDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAj\n" + "TDEWMBQGA1UEChMNU3RhcnRDb20gTHRkLjErMCkGA1UECxMiU2VjdXJlIERpZ2l0\n" +
"BgNVBAoTHFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xOTA3BgNVBAsTMGh0\n" + "YWwgQ2VydGlmaWNhdGUgU2lnbmluZzE4MDYGA1UEAxMvU3RhcnRDb20gQ2xhc3Mg\n" +
"dHA6Ly9jZXJ0aWZpY2F0ZXMuc3RhcmZpZWxkdGVjaC5jb20vcmVwb3NpdG9yeTEx\n" + "MiBQcmltYXJ5IEludGVybWVkaWF0ZSBTZXJ2ZXIgQ0EwHhcNMTQwODIxMjEwMDI4\n" +
"MC8GA1UEAxMoU3RhcmZpZWxkIFNlY3VyZSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0\n" + "WhcNMTYwODIxMDY0NDE0WjCBlDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlm\n" +
"eTERMA8GA1UEBRMIMTA2ODg0MzUwHhcNMTExMDA1MDI1MTQyWhcNMTQxMDA1MDI1\n" + "b3JuaWExFj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LnNlcnZlci5jYS5jcnQwIwYDVR0SBBwwGoYYaHR0cDovL3d3dy5zdGFydHNz\n" +
"zkVBz5DhpshQe97x6OGLOA==\n" + "bC5jb20vMA0GCSqGSIb3DQEBCwUAA4IBAQBVkvlwVLfnTNZh1c8j+PQ1t2n6x1dh\n" +
"tQtZiAYWKvZwi+XqLwU8q2zMxKrTDuqyEVyfCtWCiC1Vkpz72pcyXz2dKu7F7ZVL\n" +
"86uVHcc1jAGmL59UCXz8LFbfAMcoVQW1f2WtNwsa/WGnPUes3jFSec+shB+XCpvE\n" +
"WU6mfcZD5TyvbC79Kn5e3Iq+B4DaXhU/BXASRbORgYd8C+dqj++w0PAcMrmjn3D6\n" +
"EmL1ofqpQ8wCJd5C1b5Fr4RbbYpK8v8AASRcp2Qj9WJjyV882FvXOOFj5V2Jjcnh\n" +
"G0h67ElS/klu9rPaZ+vr3iIB56wvk08O2Wq1IND3sN+Ke3UsvuPqDxAv\n" +
"-----END CERTIFICATE-----\n"; "-----END CERTIFICATE-----\n";
private File mKeyStoreFile; private File mKeyStoreFile;
@ -167,7 +179,7 @@ public class TrustManagerFactoryTest extends AndroidTestCase {
private X509Certificate mCert2; private X509Certificate mCert2;
private X509Certificate mCaCert; private X509Certificate mCaCert;
private X509Certificate mCert3; private X509Certificate mCert3;
private X509Certificate mStarfieldCert; private X509Certificate mLinuxComFirstParentCert;
private X509Certificate mLinuxComCert; private X509Certificate mLinuxComCert;
@ -176,7 +188,7 @@ public class TrustManagerFactoryTest extends AndroidTestCase {
mCert2 = loadCert(K9_EXAMPLE_COM_CERT2); mCert2 = loadCert(K9_EXAMPLE_COM_CERT2);
mCaCert = loadCert(CA_CERT); mCaCert = loadCert(CA_CERT);
mCert3 = loadCert(CERT3); mCert3 = loadCert(CERT3);
mStarfieldCert = loadCert(STARFIELD_CERT); mLinuxComFirstParentCert = loadCert(LINUX_COM_FIRST_PARENT_CERT);
mLinuxComCert = loadCert(LINUX_COM_CERT); mLinuxComCert = loadCert(LINUX_COM_CERT);
} }
@ -267,20 +279,20 @@ public class TrustManagerFactoryTest extends AndroidTestCase {
public void testGloballyTrustedCertificateChain() throws Exception { public void testGloballyTrustedCertificateChain() throws Exception {
X509TrustManager trustManager = TrustManagerFactory.get("www.linux.com", PORT1); X509TrustManager trustManager = TrustManagerFactory.get("www.linux.com", PORT1);
X509Certificate[] certificates = new X509Certificate[] { mLinuxComCert, mStarfieldCert }; X509Certificate[] certificates = new X509Certificate[] { mLinuxComCert, mLinuxComFirstParentCert};
trustManager.checkServerTrusted(certificates, "authType"); trustManager.checkServerTrusted(certificates, "authType");
} }
public void testGloballyTrustedCertificateNotMatchingHost() throws Exception { public void testGloballyTrustedCertificateNotMatchingHost() throws Exception {
X509TrustManager trustManager = TrustManagerFactory.get(NOT_MATCHING_HOST, PORT1); X509TrustManager trustManager = TrustManagerFactory.get(NOT_MATCHING_HOST, PORT1);
assertCertificateRejection(trustManager, new X509Certificate[] { mLinuxComCert, mStarfieldCert }); assertCertificateRejection(trustManager, new X509Certificate[] { mLinuxComCert, mLinuxComFirstParentCert});
} }
public void testGloballyTrustedCertificateNotMatchingHostOverride() throws Exception { public void testGloballyTrustedCertificateNotMatchingHostOverride() throws Exception {
mKeyStore.addCertificate(MATCHING_HOST, PORT1, mLinuxComCert); mKeyStore.addCertificate(MATCHING_HOST, PORT1, mLinuxComCert);
X509TrustManager trustManager = TrustManagerFactory.get(MATCHING_HOST, PORT1); X509TrustManager trustManager = TrustManagerFactory.get(MATCHING_HOST, PORT1);
X509Certificate[] certificates = new X509Certificate[] { mLinuxComCert, mStarfieldCert }; X509Certificate[] certificates = new X509Certificate[] { mLinuxComCert, mLinuxComFirstParentCert};
trustManager.checkServerTrusted(certificates, "authType"); trustManager.checkServerTrusted(certificates, "authType");
} }