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());
}
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);
}
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;
}
}
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());
}
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;
}
Aggregations