如何使用.KEY和.pem文件创建在Android的一个插座SSL? [英] How to use .key and .pem file to create a socket SSL in Android?
问题描述
我的.key文件,如:
----- BEGIN RSA私钥-----
MIIEpAIBAAKCAQEA1j6eGXbHpqigZ1K // wnuyr5v / L2jFm7dzTtHJx8ZoMQ4CbsG
My .key file like: -----BEGIN RSA PRIVATE KEY----- MIIEpAIBAAKCAQEA1j6eGXbHpqigZ1K//wnuyr5v/L2jFm7dzTtHJx8ZoMQ4CbsG
我的.pem文件,如:
----- BEGIN CERTIFICATE -----
MIIE4zCCA8ugAwIBAgIDBOziMA0GCSqGSIb3DQEBBQUAMDwxCzAJBgNVBAYTAlVT
My .pem file like: -----BEGIN CERTIFICATE----- MIIE4zCCA8ugAwIBAgIDBOziMA0GCSqGSIb3DQEBBQUAMDwxCzAJBgNVBAYTAlVT
我不知道身份验证的多少步在这里。我只是想创建一个SSL套接字到一个IP和端口,发送/在套接字接收数据。
我试图用keystock,但也许我不明白深约吧,我总是错的。
I don't know how many steps of authenticate at here. I only want to create a ssl socket to an IP and port, and send/receive data in that socket. I tried to use keystock, but perhaps I don't understand deep about it, I always get wrong.
请给我指导,或来样code。
Please give me a guide, or sample code.
太感谢了。
推荐答案
我假设 .KEY
和质子交换膜
文件重新presents你必须使用用于执行HTTPS客户端身份验证客户端证书。不幸的Java / Android的prefers不同的格式,因此,我建议你两个文件导入到 BKS
文件。
I assume that the .key
and .pem
file represents your client certificate you have to use for performing an HTTPS client authentication. Unfortunately Java/Android prefers a different format, therefore I recommend you to import both file into a BKS
file.
创建 BKS
文件,并导入现有 .KEY
+ 质子交换膜
文件中使用 Portecle GUI 是很简单的。开始Portecle选择的文件后 - >新的密钥库 - > BKS 的。之后,您可以执行的工具 - >导入密钥对的选择.pem文件。随后Portecle会问你选择.key文件。
Creating a BKS
file and importing existing .key
+.pem
file is very simple using Portecle GUI. After starting Portecle select File -> New Keystore -> BKS. Afterwards you can execute Tools -> Import Key Pair and select the .pem file. Afterwards Portecle will ask you for selecting the .key file.
最后保存在您选择的密码保护的密钥存储区。
Finally save the key store protected with a password of your choice.
创建的 BKS
文件现在可以在Android应用中使用。例如,见code张贴在这个问题:<一href=\"http://stackoverflow.com/questions/4064810/using-client-server-certificates-for-two-way-authentication-ssl-socket-on-androi\">Using在Android 的双向认证的SSL套接字的客户机/服务器证书
The created BKS
file can now be used in your Android app. See for example the code posted in this question: Using client/server certificates for two way authentication SSL socket on Android
更新2015年6月30日:上面的描述仅适用于Portecle 1.6及以前。随着1.7版和1.8不能创建的Android兼容密钥库。在Portecle 1.9使用格式为: BKS-V1
代替。
Update 2015-06-30: The description above works only for Portecle 1.6 and before. With version 1.7 and 1.8 you can not create android compatible keystores. In Portecle 1.9 use the format BKS-V1
instead.
这篇关于如何使用.KEY和.pem文件创建在Android的一个插座SSL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!