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 服務器

1、參考:http://www.cnblogs.com/aixiaoxiaoyu/articles/8796410.html
2、進入存放證書、公鑰、私鑰 的目錄
    服務端 (/Users/dhbm/Desktop/lxn/lxntransfer/tests)
    cd  /Users/dhbm/Desktop/lxn/lxntransfer/tests
3、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)
1、參考:http://www.cnblogs.com/aixiaoxiaoyu/articles/8796398.html
客戶端證書位置 (/Users/dhbm/Desktop/lxn/lxntransfer/testc)
	cd /Users/dhbm/Desktop/lxn/lxntransfer/testc
2、本機測試
    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 參數?自己就能找到?
4、連接另一個服務器,另一個端口測試
    s_client -connect 192.168.1.166:5060
    別人提供的 ubuntu 服務器,server.c編譯運行在 192.168.1.166,端口是 5060
5、運行結果
    沒有帶上參數的時候,錯誤信息
    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 端都是顯示出來
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章