use of org.apache.harmony.security.provider.cert.X509CertImpl in project XobotOS by xamarin.
the class AbstractSessionContext method toSession.
/**
* Creates a session from the given bytes.
*
* @return a session or null if the session can't be converted
*/
SSLSession toSession(byte[] data, String host, int port) {
ByteArrayInputStream bais = new ByteArrayInputStream(data);
DataInputStream dais = new DataInputStream(bais);
try {
int type = dais.readInt();
if (type != OPEN_SSL) {
log(new AssertionError("Unexpected type ID: " + type));
return null;
}
int length = dais.readInt();
byte[] sessionData = new byte[length];
dais.readFully(sessionData);
int count = dais.readInt();
X509CertImpl[] certs = new X509CertImpl[count];
for (int i = 0; i < count; i++) {
length = dais.readInt();
byte[] certData = new byte[length];
dais.readFully(certData);
certs[i] = new X509CertImpl(certData);
}
return new OpenSSLSessionImpl(sessionData, host, port, certs, this);
} catch (IOException e) {
log(e);
return null;
}
}
use of org.apache.harmony.security.provider.cert.X509CertImpl 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 org.apache.harmony.security.provider.cert.X509CertImpl 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;
}
}
Aggregations