Mac openssl 开发环境测试
准备工做
1. 别人给个人他在 ubuntu 下的 openssl 1.0.2o以及他本身写的 client.c,server.c ,他生成的证书等
2. 个人重点在于搭建一个能够测试 client.c 程序的服务器环境
3. 把他提供的程序、证书都放到 /Users/dhbm/Desktop/lxn/lxntransfer/tests
建立一个 openssl 服务器
一、参考:http://www.cnblogs.com/aixiaoxiaoyu/articles/8796410.html
二、进入存放证书、公钥、私钥 的目录
服务端 (/Users/dhbm/Desktop/lxn/lxntransfer/tests)
cd /Users/dhbm/Desktop/lxn/lxntransfer/tests
三、openssl s_server -key server-key.pem -cert server-cert.pem
参数说明:
-cert filename
证书文件名
-key filename
私钥文件
运行结果:
Using default temp DH parameters
ACCEPT
创建客户端
链接到 openssl 服务器(Mac 的 openssl s_server缺省端口是 4433)
一、参考:http://www.cnblogs.com/aixiaoxiaoyu/articles/8796398.html
客户端证书位置 (/Users/dhbm/Desktop/lxn/lxntransfer/testc)
cd /Users/dhbm/Desktop/lxn/lxntransfer/testc
二、本机测试
openssl s_client -connect 127.0.0.1:4433
或者本机ip (个人ip是 192.168.1.100 如下列举个人几个虚拟机ip,纯粹为了我本身 copy 方便)
openssl s_client -connect 192.168.1.199:4433
openssl s_client -connect 192.168.1.166:4433
openssl s_client -connect 192.168.1.177:4433
openssl s_client -connect 192.168.1.100:4433
运行结果
Server is connect to you!
有个疑问:为何不用加上 key cert 参数?本身就能找到?
四、链接另外一个服务器,另外一个端口测试
s_client -connect 192.168.1.166:5060
别人提供的 ubuntu 服务器,server.c编译运行在 192.168.1.166,端口是 5060
五、运行结果
没有带上参数的时候,错误信息
find a customer to try to connect
can not find the customer's certificate
完整命令
** 只是为了本身操做方便,因此按照本身的环境复制,留在这里,每次直接从这里 copy
cd /Users/dhbm/Desktop/lxn/lxntransfer/testc
openssl s_client -connect 192.168.1.166:5060 -key client-key.pem -cert client-cert.pem
运行结果
Server is connect to you!
openssl s_client -connect 192.168.1.100:4433 -key client-key.pem -cert client-cert.pem
运行结果:
同上!
客户端的输入发送(回车),在 2 端都是显示出来
openssl s_client -connect 192.168.1.199:4433 -key client-key.pem -cert client-cert.pem
openssl s_client -connect 127.0.0.1:4433 -key client-key.pem -cert client-cert.pem
运行结果:
同上!
客户端的输入发送(回车),在 2 端都是显示出来