Linux下匯入SSL認證(配置用於Apache)

來源:互聯網
上載者:User

標籤:https ssl

三、部署認證

如果使用雙向認證,就會有三個私密金鑰和三個認證。分別是 ca.key, ca.crt, server.key, server.crt, client.key, client.crt ,以及給瀏覽器的 client.pfx 。
如果使用有 CA 憑證的單向認證,認證和私密金鑰就是 ca.key, ca.crt, server.key, server.crt 。
如果使用無 CA 憑證的單向認證,認證和私密金鑰就是 server.key, server.crt 。

1、修改httpd.conf檔案

**RPM安裝的情況下,不需要修改httpd.conf檔案,因為在httpd.conf檔案中預設添加了 include conf.d/*.conf。而在rpm安裝時,conf.d檔案夾中已含有ssl.conf檔案。所以只要修改ssl.conf檔案就可以了。**

**RPM安裝的Apahce時,可能一開始沒有mod-ssl,需要安裝。方法為:yum install mod_ssl 或者用rpm包安裝,需要mod_ssl arp_util distcache httpd postgresql-libs等伊來關係。**

需要修改時可在httpd.conf檔案中加上include conf.d/ssl.conf(用於ssl模組使用的conf檔案的路徑即可)。

2、修改ssl.conf檔案

[[email protected] conf.d]#cp -p ssl.conf ssl.conf.bk

[[email protected] conf.d]#vi ssl.conf

---------------------------------------

Listen 443 //可以改成其他連接埠
SSLPassPhraseDialog builtin //每次重啟Apache時需要輸入密碼
SSLSessionCache shmcb:/var/cache/mod_ssl/scache(512000)
SSLSessionCacheTimeout 300
SSLMutex default
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin

<VirtualHost _default_:443>
SSLEngine on
SSLCertificateFile /etc/httpd/conf/ssl.crt/server.crt
SSLCertificateKeyFile /etc/httpd/conf/ssl.crt/server.key

SSLCACertificateFile /etc/httpd/conf/ssl.crt/ca.crt //雙向時使用
SSLVerifyClient require //雙向時使用,強制客戶必須持有SSL認證請求
SSLVerifyDepth 10 //雙向時使用
</VirtualHost>

---------------------------------------

可以按照如下方式重新匯入KEY檔案,則可以不用每次重啟Apache都需要輸入KEY檔案密碼

[[email protected] ssl.crt]#openssl rsa -in server.key -out server2.key
[[email protected] ssl.crt]#mv server.key server.key.originalkey
[[email protected] ssl.crt]#mv server2.key server.key

3、重啟Apache

[[email protected] ssl.crt]#service httpd restart

如果連接埠號碼為非預設的443(假如為446),則可能會會出現如下錯誤:

Starting httpd: (13)Permission denied: make_sock: could not bind to address [::]:446
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:446
no listening sockets available, shutting down
Unable to open logs
[FAILED]

則可以使用semanagement工具來添加Apache的偵聽連接埠

[[email protected] ssl.crt]#semanage port -l|grep http
[[email protected] ssl.crt]#semanage port -a -t http_port_t -p tcp 446

再次重啟Apache應該就可以使用了。

4、開啟防火牆連接埠

[[email protected] conf]#cd /etc/sysconfig/
[[email protected] conf]#vi iptables
-------------------------------------
添加
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 446 -j ACCEPT
-------------------------------------
[[email protected] sysconfig]# /etc/init.d/iptables restart

配置完之後,如果用戶端沒有安裝認證,則不能用446連接埠訪問伺服器了。

5、用戶端安裝認證

IE為例:
【工具】--》【internet選項】--》【內容】--》【認證】--》【可信任的根憑證授權單位】--》【匯入】,匯入ca.crt。
(雙向認證時)【工具】--》【internet選項】--》【內容】--》【認證】--》【個人】--》【匯入】,匯入client.p12,需要輸入該檔案的密碼
可使用https訪問網站

*如果使用IE訪問時有問題而用其他瀏覽器比如Firefox,Google時沒有問題,請對IE做以下設定:
【工具】--》【internet選項】--》【進階】--》安全
ssl和tls使用最低版本。比如SSL 勾選【使用SSL 2.0】,其他的ssl版本不勾選
tls勾選【使用TLS 1.0】,其他版本的tsl不勾選
*其他瀏覽器操作類似,有問題可以百度搜尋。


本文出自 “夢想照進現實” 部落格,請務必保留此出處http://lookingdream.blog.51cto.com/5177800/1870099

Linux下匯入SSL認證(配置用於Apache)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.