Search in sources :

Example 11 with SslCertificate

use of android.net.http.SslCertificate in project platform_frameworks_base by android.

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());
}
Also used : SslCertificate(android.net.http.SslCertificate) X509Certificate(java.security.cert.X509Certificate) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 12 with SslCertificate

use of android.net.http.SslCertificate in project XobotOS by xamarin.

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 {
        X509Certificate cert = new X509CertImpl(certDER);
        SslCertificate sslCert = new SslCertificate(cert);
        sslError = SslError.SslErrorFromChromiumErrorCode(certError, sslCert, url);
    } catch (IOException 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);
            nativeSslCertErrorProceed(handle);
        }

        @Override
        public void cancel() {
            nativeSslCertErrorCancel(handle, certError);
        }
    };
    mCallbackProxy.onReceivedSslError(handler, sslError);
}
Also used : SslCertificate(android.net.http.SslCertificate) SslError(android.net.http.SslError) X509CertImpl(org.apache.harmony.security.provider.cert.X509CertImpl) IOException(java.io.IOException) X509Certificate(java.security.cert.X509Certificate)

Example 13 with SslCertificate

use of android.net.http.SslCertificate in project XobotOS by xamarin.

the class BrowserFrame method setCertificate.

/**
     * Called by JNI when we recieve a certificate for the page's main resource.
     * Used by the Chromium HTTP stack only.
     */
private void setCertificate(byte[] cert_der) {
    try {
        X509Certificate cert = new X509CertImpl(cert_der);
        mCallbackProxy.onReceivedCertificate(new SslCertificate(cert));
    } catch (IOException e) {
        // Can't get the certificate, not much to do.
        Log.e(LOGTAG, "Can't get the certificate from WebKit, canceling");
        return;
    }
}
Also used : SslCertificate(android.net.http.SslCertificate) X509CertImpl(org.apache.harmony.security.provider.cert.X509CertImpl) IOException(java.io.IOException) X509Certificate(java.security.cert.X509Certificate)

Example 14 with SslCertificate

use of android.net.http.SslCertificate in project android_frameworks_base by AOSPA.

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());
}
Also used : SslCertificate(android.net.http.SslCertificate) X509Certificate(java.security.cert.X509Certificate) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 15 with SslCertificate

use of android.net.http.SslCertificate in project chromeview by pwnall.

the class AwContentsClientBridge method allowCertificateError.

// If returns false, the request is immediately canceled, and any call to proceedSslError
// has no effect. If returns true, the request should be canceled or proceeded using
// proceedSslError().
// Unlike the webview classic, we do not keep keep a database of certificates that
// are allowed by the user, because this functionality is already handled via
// ssl_policy in native layers.
@CalledByNative
private boolean allowCertificateError(int certError, byte[] derBytes, final String url, final int id) {
    final SslCertificate cert = SslUtil.getCertificateFromDerBytes(derBytes);
    if (cert == null) {
        // if the certificate or the client is null, cancel the request
        return false;
    }
    final SslError sslError = SslUtil.sslErrorFromNetErrorCode(certError, cert, url);
    ValueCallback<Boolean> callback = new ValueCallback<Boolean>() {

        @Override
        public void onReceiveValue(Boolean value) {
            proceedSslError(value.booleanValue(), id);
        }
    };
    mClient.onReceivedSslError(callback, sslError);
    return true;
}
Also used : ValueCallback(android.webkit.ValueCallback) SslCertificate(android.net.http.SslCertificate) SslError(android.net.http.SslError) CalledByNative(org.chromium.base.CalledByNative)

Aggregations

SslCertificate (android.net.http.SslCertificate)20 X509Certificate (java.security.cert.X509Certificate)18 LargeTest (android.test.suitebuilder.annotation.LargeTest)12 IOException (java.io.IOException)4 SslError (android.net.http.SslError)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 CertificateFactory (java.security.cert.CertificateFactory)3 NotFoundException (android.content.res.Resources.NotFoundException)2 ParseException (android.net.ParseException)2 X509CertImpl (org.apache.harmony.security.provider.cert.X509CertImpl)2 Context (android.content.Context)1 Bundle (android.os.Bundle)1 ValueCallback (android.webkit.ValueCallback)1 LinearLayout (android.widget.LinearLayout)1 Certificate (java.security.cert.Certificate)1 CertificateException (java.security.cert.CertificateException)1 CalledByNative (org.chromium.base.CalledByNative)1