use of javax.net.ssl.X509TrustManager in project k-9 by k9mail.
the class TrustManagerFactoryTest method testLocallyTrustedCertificateChain.
@Test
public void testLocallyTrustedCertificateChain() throws Exception {
mKeyStore.addCertificate(MATCHING_HOST, PORT1, mCert3);
X509TrustManager trustManager = TrustManagerFactory.get(MATCHING_HOST, PORT1);
trustManager.checkServerTrusted(new X509Certificate[] { mCert3, mCaCert }, "authType");
}
use of javax.net.ssl.X509TrustManager in project k-9 by k9mail.
the class TrustManagerFactoryTest method testCertificateOfOtherHost.
@Test
public void testCertificateOfOtherHost() throws Exception {
mKeyStore.addCertificate(MATCHING_HOST, PORT1, mCert1);
mKeyStore.addCertificate(MATCHING_HOST, PORT2, mCert2);
X509TrustManager trustManager = TrustManagerFactory.get(MATCHING_HOST, PORT1);
assertCertificateRejection(trustManager, new X509Certificate[] { mCert2 });
}
use of javax.net.ssl.X509TrustManager in project k-9 by k9mail.
the class TrustManagerFactoryTest method testLocallyTrustedCertificateChainNotMatchingHost.
@Test
public void testLocallyTrustedCertificateChainNotMatchingHost() throws Exception {
mKeyStore.addCertificate(NOT_MATCHING_HOST, PORT1, mCert3);
X509TrustManager trustManager = TrustManagerFactory.get(NOT_MATCHING_HOST, PORT1);
trustManager.checkServerTrusted(new X509Certificate[] { mCert3, mCaCert }, "authType");
}
use of javax.net.ssl.X509TrustManager in project k-9 by k9mail.
the class TrustManagerFactoryTest method testGloballyTrustedCertificateNotMatchingHost.
@Test
public void testGloballyTrustedCertificateNotMatchingHost() throws Exception {
X509TrustManager trustManager = TrustManagerFactory.get(NOT_MATCHING_HOST, PORT1);
assertCertificateRejection(trustManager, new X509Certificate[] { mLinuxComCert, mLinuxComFirstParentCert });
}
use of javax.net.ssl.X509TrustManager in project scdl by passy.
the class PinningTrustManagerImpl method checkServerTrusted.
@Override
public void checkServerTrusted(final X509Certificate[] chain, final String authType) throws CertificateException {
Log.d(TAG, "Checking if server is trusted");
for (final TrustManager systemTrustManager : systemTrustManagers) {
((X509TrustManager) systemTrustManager).checkServerTrusted(chain, authType);
}
Log.d(TAG, "Getting trust root");
final X509Certificate anchor = systemKeyStore.getTrustRoot(chain);
Log.d(TAG, "checking certs for valid pin");
for (final X509Certificate certificate : chain) {
if (isValidPin(certificate)) {
Log.d(TAG, "Success!");
return;
}
}
Log.d(TAG, "checking anchor for valid pin");
if (anchor != null && isValidPin(anchor)) {
Log.d(TAG, "Success!");
return;
}
throw new CertificateException("No valid Pins found in Certificate Chain!");
}
Aggregations