CentOS生成自签名证书配置Apache https
生活随笔
收集整理的這篇文章主要介紹了
CentOS生成自签名证书配置Apache https
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
CentOS生成自簽名證書配置Apache https
Issued by: localhost.localdomian
頒發者: localhost.localdomain
頒發給: localhost.localdomain
----------------------------------------------------------------------
下面我們生成自簽證書
3.生成密鑰
openssl genrsa -out test.com.key 2048
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:Beijing
Locality Name (eg, city) [Default City]:Beijing
Organization Name (eg, company) [Default Company Ltd]:test.com
Organizational Unit Name (eg, section) []:test
Common Name (eg, your name or your server's hostname) []:www.test.com
to be sent with your certificate request
A challenge password []:123456
cp test.com.key /etc/pki/tls/private/
cp test.com.csr /etc/pki/tls/private/
SSLCertificateFile /etc/pki/tls/certs/test.com.crt
SSLCertificateKeyFile /etc/pki/tls/private/test.com.key
Issued by: www.test.com
頒發者: www.test.com
頒發給: www.test.com
apache的安裝就不用說了
1.安裝完apache之后,安裝mod_ssl和openssl
yum install mod_ssl openssl
2.安裝完成之后,配置iptables打開443端口, 這時其實已經可以訪問https了,但是我們看證書詳情的時候顯示
Issued to: localhost.localdomainIssued by: localhost.localdomian
頒發者: localhost.localdomain
頒發給: localhost.localdomain
----------------------------------------------------------------------
下面我們生成自簽證書
3.生成密鑰
openssl genrsa -out test.com.key 2048
4. 生成證書請求文件,運行之后會出現一大堆要輸入的東西,輸入之后就生成.csr的文件了
openssl req -new -key test.com.key -out test.com.csrYou are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:Beijing
Locality Name (eg, city) [Default City]:Beijing
Organization Name (eg, company) [Default Company Ltd]:test.com
Organizational Unit Name (eg, section) []:test
Common Name (eg, your name or your server's hostname) []:www.test.com
Email Address []:root@test.com
Please enter the following 'extra' attributesto be sent with your certificate request
A challenge password []:123456
An optional company name []:test
5.生成證書crt
openssl x509 -req -days 365 -in test.com.csr -signkey test.com.key -out test.com.crt6.復制文件到相應的目錄
cp test.com.crt /etc/pki/tls/certscp test.com.key /etc/pki/tls/private/
cp test.com.csr /etc/pki/tls/private/
7.修改配置文件
vim /etc/httpd/conf.d/ssl.confSSLCertificateFile /etc/pki/tls/certs/test.com.crt
SSLCertificateKeyFile /etc/pki/tls/private/test.com.key
8.重啟apache
service httpd restart9.這時再使用https訪問,查看證書詳情的時候就會看到
Issued to: www.test.comIssued by: www.test.com
頒發者: www.test.com
頒發給: www.test.com
總結
以上是生活随笔為你收集整理的CentOS生成自签名证书配置Apache https的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: phpsocket服务端和VC客户端通信
- 下一篇: CentOS挂载NTFS移动硬盘