Mac openssl 開發環境測試

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 端都是顯示出來
相關文章
相關標籤/搜索