基於openssl實現C/S架構中的https會話

來源:互聯網
上載者:User

在實際生產中實現公司內部的web伺服器加密訪問時,我們就需要實現公司內部的私密金鑰CA,並且完成對web伺服器的簽署請求,這樣我們就可以在自身的內部機構實現對資料的機密性、完整性、身分識別驗證的訪問與傳輸實驗的準備:實驗是在vm9上完成的,一共用了兩台虛擬機器;一台在CA簽署伺服器IP地址是172.16.51.18),另一台是web伺服器IP地址是172.16.51.17)私人CA的實現包括有自身私密金鑰的產生、產生自簽認證、準備相關的檔案實現私人CA的準備為CA提供私密金鑰650) this.width=650;" border="0" alt="" src="http://www.bkjia.com/uploads/allimg/131227/1915063503-0.jpg" /> 產生自簽認證650) this.width=650;" border="0" alt="" src="http://www.bkjia.com/uploads/allimg/131227/19150A596-1.jpg" />產生自簽認證的時候,會讓我們填寫一些資訊,例如國家,省,市,公司名稱等這些資訊可以直接在/etc/pki/tls/openssl.cnf設定檔中更改這些預設的資訊。修改/etc/pki/tls/openssl.cnf設定檔中關於認證存放位置,並查看CA認證所需要的檔案及目錄650) this.width=650;" border="0" alt="" src="http://www.bkjia.com/uploads/allimg/131227/19150645Q-2.jpg" /> 手動建立certs crl newcerts目錄並建立index.txt檔案與serial檔案並指定起始號)650) this.width=650;" border="0" alt="" src="http://www.bkjia.com/uploads/allimg/131227/19150BB5-3.jpg" />現在一個我們自簽署的CA就可以使用了web伺服器端的準備首先自己要準備好web服務,安裝httpd軟體包就可以了,要實現ssl功能需要安裝ssl模組,所以模組要確保安裝上安裝ssl模組yum install mod_ssl為web伺服器的認證申請以及密鑰檔案存放建立一個特定的目錄mkdir /etc/httpd/conf/sslcd /etc/httpd/conf/ssl把公開金鑰封裝成認證申請請求,向CA申請簽署;首先要自己產生一個私密金鑰存放密鑰的檔案許可權是600的)650) this.width=650;" border="0" alt="" src="http://www.bkjia.com/uploads/allimg/131227/1915064912-4.jpg" />重新啟動httpd服務,載入新添加的模組service httpd restart簽署請求申請前查看自己的FQDN,沒有指定的可以直接更改/etc/hosts設定檔添加一條對應關係就可以了650) this.width=650;" border="0" alt="" src="http://www.bkjia.com/uploads/allimg/131227/1915061I7-5.jpg" />產生認證簽署請求650) this.width=650;" border="0" alt="" src="http://www.bkjia.com/uploads/allimg/131227/19150645B-6.jpg" />把簽署請求發送給CA伺服器端現實中為了確保其安全性,需要手動複製簽署請求到CA認證機構去簽署;避免在網路傳輸中資料泄露)現在直接使用scp發送到CA伺服器端650) this.width=650;" border="0" alt="" src="http://www.bkjia.com/uploads/allimg/131227/19150645E-7.jpg" />在CA伺服器端完成簽署650) this.width=650;" border="0" alt="" src="http://www.bkjia.com/uploads/allimg/131227/1915063191-8.jpg" />簽署完成後查看CA機構的認證相關檔案的變化650) this.width=650;" border="0" alt="" src="http://www.bkjia.com/uploads/allimg/131227/1915063453-9.jpg" />在web伺服器端把簽署的認證複製過來scp 172.16.51.18:/tmp/httpd.crt /etc/httpd/conf/ssl/認證簽署後為了安全刪除CA端的檔案rm -rf httpd.crtrm -rf httpd.csr更改web伺服器的/etc/httpd/conf.d/ssl.conf設定檔中心主機的設定650) this.width=650;" border="0" alt="" src="http://www.bkjia.com/uploads/allimg/131227/19150C1Z-10.jpg" />密鑰及認證檔案位置的指定650) this.width=650;" border="0" alt="" src="http://www.bkjia.com/uploads/allimg/131227/1915061914-11.jpg" />建立/var/www/html目錄下的首頁index.html,並且添加一些內容,方便後面的驗證650) this.width=650;" border="0" alt="" src="http://www.bkjia.com/uploads/allimg/131227/19150C917-12.jpg" />一切都修改完成後檢查一下語法錯誤並且重啟一下httpd服務httpd –tservice httpd restart把CA的認證傳遞給物理主機一份,進行測試複製/etc/pki/CA/cacert.pem到物理主機,複製到windows系統後把cacert.pem檔案的名稱更改成cacert.crt650) this.width=650;" border="0" alt="" src="http://www.bkjia.com/uploads/allimg/131227/19150C135-13.jpg" />點擊安裝認證按鈕,將認證安裝到受信任的節點中,然後就可以實現對web伺服器的加密訪問了650) this.width=650;" border="0" alt="" src="http://www.bkjia.com/uploads/allimg/131227/1915064919-14.jpg" />

本文出自 “鄧俊陽的Blog” 部落格,請務必保留此出處http://djy0000.blog.51cto.com/5816828/1175224

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.