我正在尝试通过 Android 的 HttpClient
使用自签名客户端和服务器证书连接到 HTTPS 网络服务器。证书和私钥都存储在 PKCS#12 keystore 中。
我正在使用 this example加载 keystore 的区别:
KeyStore trustStore = KeyStore.getInstance("PKCS12");
trustStore.load(new FileInputStream(keystoreFile), "mypass".toCharArray());
keystore 正确加载,因为我能够列出其中的所有证书。
但是,在执行 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)
我正在运行 OS 2.3.4 的 Nexus S 和运行 OS 2.2 的 HTC Desire 以及运行 OS 2.1 的模拟器上进行测试。它们都产生相同的错误。我看了s3_pkt.c:1053但不明白可能是什么问题。
有什么想法吗?
最佳答案
trustStore.load(new FileInputStream(keystoreFile), "mypass".toCharArray());
您似乎混淆了 keystore 和信任库。 keystore 包含您的私钥和证书。信任库包含其他人的证书。
关于android - 使用自签名证书的 HTTPS 产生握手错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7340057/