I’m trying to connect to a HTTPS web server via Android’s HttpClient with a self-signed client and server certificates. Both certs and private key are stored in PKCS#12 keystore.
I’m using this example with the difference in loading the keystore:
KeyStore trustStore = KeyStore.getInstance("PKCS12");
trustStore.load(new FileInputStream(keystoreFile), "mypass".toCharArray());
The keystore loads properly as I’m able to list all certs in it.
But, when executing the GET request I get:
09-07 22:01:05.197: ERROR/TTT(3716): IOException: java.io.IOException:
SSL handshake failure: Failure in SSL library, usually a protocol error
error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure
(external/openssl/ssl/s3_pkt.c:1127 0x2e3b40:0x00000003)
I’m testing this on Nexus S with OS 2.3.4 and HTC Desire with OS 2.2 and also emulator with OS 2.1. They all produce the same error. I looked at s3_pkt.c:1053 but couldn’t understand what the problem could be.
Any ideas?
You seem to have your keystore and your truststore confused. The keystore contains your private key and certificate. The truststore contains other people’s certificates.