我有一个Python SSL服务器和客户端,但我的应用程序需要一个Android SSL客户端。这是我的server.crt.it
的Python客户端测试现在可以使用:
import socket, ssl, pprint
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ssl_sock = ssl.wrap_socket(s,ca_certs="server.crt",cert_reqs=ssl.CERT_REQUIRED)
ssl_sock.connect(('localhost', 10999))
ssl_sock.write("|setname|melo|\n")
data = ssl_sock.read()
print data
ssl_sock.close()
我的java客户端代码没有crt
:
SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket sslsocket = (SSLSocket) factory.createSocket("localhost", 10999);
DataOutputStream os = new DataOutputStream(sslsocket.getOutputStream());
DataInputStream is = new DataInputStream(sslsocket.getInputStream());
String str = "|setname|melo|\n";
os.writeBytes(str);
String responseStr;
if((responseStr = is.readUTF())!=null) {
System.out.println(responseStr);
}
os.close();
is.close();
sslsocket.close();
如何使用.crt
将我的SSL Python客户端转换为Android SSL客户端?
我的密钥crt csr:
openssl genrsa -des3 -out server.orig.key 2048
openssl rsa -in server.orig.key -out server.key
openssl req -new -key server.key -out server.csr
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
在此链接中有pem jks pfk文件http://juliusdavies.ca/not-yet-commons-ssl-0.3.9/ssl.html 我该如何生成它们?