Search in sources :

Example 1 with OpenSSLKey

use of org.apache.harmony.xnet.provider.jsse.OpenSSLKey in project android_frameworks_base by ParanoidAndroid.

the class ClientCertRequestHandler method proceed.

/**
     * Proceed with the specified private key and client certificate chain.
     */
public void proceed(PrivateKey privateKey, X509Certificate[] chain) {
    try {
        byte[][] chainBytes = NativeCrypto.encodeCertificates(chain);
        mTable.Allow(mHostAndPort, privateKey, chainBytes);
        if (privateKey instanceof OpenSSLKeyHolder) {
            OpenSSLKey pkey = ((OpenSSLKeyHolder) privateKey).getOpenSSLKey();
            setSslClientCertFromCtx(pkey.getPkeyContext(), chainBytes);
        } else {
            setSslClientCertFromPKCS8(privateKey.getEncoded(), chainBytes);
        }
    } catch (CertificateEncodingException e) {
        post(new Runnable() {

            public void run() {
                mBrowserFrame.nativeSslClientCert(mHandle, 0, null);
                return;
            }
        });
    }
}
Also used : OpenSSLKeyHolder(org.apache.harmony.xnet.provider.jsse.OpenSSLKeyHolder) CertificateEncodingException(java.security.cert.CertificateEncodingException) OpenSSLKey(org.apache.harmony.xnet.provider.jsse.OpenSSLKey)

Example 2 with OpenSSLKey

use of org.apache.harmony.xnet.provider.jsse.OpenSSLKey in project android_frameworks_base by ParanoidAndroid.

the class BrowserFrame method requestClientCert.

/**
     * Called by JNI when the native HTTPS stack gets a client
     * certificate request.
     *
     * We delegate the request to CallbackProxy, and route its response to
     * {@link #nativeSslClientCert(int, X509Certificate)}.
     */
private void requestClientCert(int handle, String hostAndPort) {
    SslClientCertLookupTable table = SslClientCertLookupTable.getInstance();
    if (table.IsAllowed(hostAndPort)) {
        // previously allowed
        PrivateKey pkey = table.PrivateKey(hostAndPort);
        if (pkey instanceof OpenSSLKeyHolder) {
            OpenSSLKey sslKey = ((OpenSSLKeyHolder) pkey).getOpenSSLKey();
            nativeSslClientCert(handle, sslKey.getPkeyContext(), table.CertificateChain(hostAndPort));
        } else {
            nativeSslClientCert(handle, pkey.getEncoded(), table.CertificateChain(hostAndPort));
        }
    } else if (table.IsDenied(hostAndPort)) {
        // previously denied
        nativeSslClientCert(handle, 0, null);
    } else {
        // previously ignored or new
        mCallbackProxy.onReceivedClientCertRequest(new ClientCertRequestHandler(this, handle, hostAndPort, table), hostAndPort);
    }
}
Also used : PrivateKey(java.security.PrivateKey) OpenSSLKeyHolder(org.apache.harmony.xnet.provider.jsse.OpenSSLKeyHolder) OpenSSLKey(org.apache.harmony.xnet.provider.jsse.OpenSSLKey)

Aggregations

OpenSSLKey (org.apache.harmony.xnet.provider.jsse.OpenSSLKey)2 OpenSSLKeyHolder (org.apache.harmony.xnet.provider.jsse.OpenSSLKeyHolder)2 PrivateKey (java.security.PrivateKey)1 CertificateEncodingException (java.security.cert.CertificateEncodingException)1