use of android.net.http.SslCertificate in project android_frameworks_base by ParanoidAndroid.
the class BrowserFrame method reportSslCertError.
/**
* Called by JNI when the Chromium HTTP stack gets an invalid certificate chain.
*
* We delegate the request to CallbackProxy, and route its response to
* {@link #nativeSslCertErrorProceed(int)} or
* {@link #nativeSslCertErrorCancel(int, int)}.
*/
private void reportSslCertError(final int handle, final int certError, byte[] certDER, String url) {
final SslError sslError;
try {
CertificateFactory cf = CertificateFactory.getInstance("X.509");
X509Certificate cert = (X509Certificate) cf.generateCertificate(new ByteArrayInputStream(certDER));
SslCertificate sslCert = new SslCertificate(cert);
sslError = SslError.SslErrorFromChromiumErrorCode(certError, sslCert, url);
} catch (Exception e) {
// Can't get the certificate, not much to do.
Log.e(LOGTAG, "Can't get the certificate from WebKit, canceling");
nativeSslCertErrorCancel(handle, certError);
return;
}
if (SslCertLookupTable.getInstance().isAllowed(sslError)) {
nativeSslCertErrorProceed(handle);
mCallbackProxy.onProceededAfterSslError(sslError);
return;
}
SslErrorHandler handler = new SslErrorHandler() {
@Override
public void proceed() {
SslCertLookupTable.getInstance().setIsAllowed(sslError);
post(new Runnable() {
public void run() {
nativeSslCertErrorProceed(handle);
}
});
}
@Override
public void cancel() {
post(new Runnable() {
public void run() {
nativeSslCertErrorCancel(handle, certError);
}
});
}
};
mCallbackProxy.onReceivedSslError(handler, sslError);
}
use of android.net.http.SslCertificate in project android_frameworks_base by AOSPA.
the class SslCertificateTest method testSslCertificateWithEmptyIssuer.
@LargeTest
public void testSslCertificateWithEmptyIssuer() throws Exception {
X509Certificate x509Certificate = generateCertificate(Issue1597Certificate);
assertEquals("", x509Certificate.getSubjectDN().getName());
SslCertificate sslCertificate = new SslCertificate(x509Certificate);
assertEquals("", sslCertificate.getIssuedBy().getDName());
}
use of android.net.http.SslCertificate in project android_frameworks_base by crdroidandroid.
the class SslCertificateTest method testSslCertificateWithMultipleCN.
@LargeTest
public void testSslCertificateWithMultipleCN() throws Exception {
X509Certificate x509Certificate = generateCertificate(Issue41662Certificate);
String dn = x509Certificate.getSubjectDN().getName();
assertTrue(dn, dn.contains("Posta CA 1"));
assertTrue(dn, dn.contains("Configuration"));
SslCertificate sslCertificate = new SslCertificate(x509Certificate);
assertEquals(dn, "Posta CA 1", sslCertificate.getIssuedTo().getCName());
}
use of android.net.http.SslCertificate in project android_frameworks_base by ParanoidAndroid.
the class SslCertificateTest method testSslCertificateWithMultipleCN.
@LargeTest
public void testSslCertificateWithMultipleCN() throws Exception {
X509Certificate x509Certificate = generateCertificate(Issue41662Certificate);
String dn = x509Certificate.getSubjectDN().getName();
assertTrue(dn, dn.contains("Posta CA 1"));
assertTrue(dn, dn.contains("Configuration"));
SslCertificate sslCertificate = new SslCertificate(x509Certificate);
assertEquals(dn, "Posta CA 1", sslCertificate.getIssuedTo().getCName());
}
use of android.net.http.SslCertificate in project android_frameworks_base by ParanoidAndroid.
the class SslCertificateTest method testSslCertificateWithEmptyIssuer.
@LargeTest
public void testSslCertificateWithEmptyIssuer() throws Exception {
X509Certificate x509Certificate = generateCertificate(Issue1597Certificate);
assertEquals("", x509Certificate.getSubjectDN().getName());
SslCertificate sslCertificate = new SslCertificate(x509Certificate);
assertEquals("", sslCertificate.getIssuedBy().getDName());
}
Aggregations