標籤:
---web伺服器---
#yum install httpd -y
#service httpd start
#chkconfig httpd on
#vi /var/www/html/index.html
---------------
<h1>http://www.baidu.com
<br>172.16.254.101
---------------
# openssl genrsa 1024 > web.key
//製作一個1024長度的私密金鑰
# openssl req -new -key web.key -days 365 -out web.csr
//產生一個簽章要求
//req --- openssl中的子命令用來做認證及簽章要求
//-new --- 建立一個
//-key --- 指定私密金鑰
//-days --- 有效期間
//-out --- 輸出
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) []:liaoning
Locality Name (eg, city) [Default City]:shenyang
Organization Name (eg, company) [Default Company Ltd]:uplooking
Organizational Unit Name (eg, section) []:instructor
Common Name (eg, your name or your server‘s hostname) []:s1.uplooking.com
Email Address []:[email protected]
Please enter the following ‘extra‘ attributes
to be sent with your certificate request
A challenge password []: <按斷行符號>
An optional company name []: <按斷行符號>
#scp /root/web.csr s2:/root
---CA認證機構---
--->將s1的簽章要求web.csr簽發產生web.crt
s2現在並不是一個CA認證機構
需要先將s2部署成為CA認證機構
部署CA認證機構比較繁瑣,
我們使用錯誤提示的方式構建CA認證機構,
並簽發籤名請求
# openssl ca -in web.csr -out web.crt //直接簽發看錯誤提示
Using configuration from /etc/pki/tls/openssl.cnf
Error opening CA private key /etc/pki/CA/private/cakey.pem
# openssl genrsa 1024 > /etc/pki/CA/private/cakey.pem
//產生CA認證機構所需的私密金鑰
# openssl ca -in web.csr -out web.crt
Using configuration from /etc/pki/tls/openssl.cnf
Error opening CA certificate /etc/pki/CA/cacert.pem
# openssl req -new -key /etc/pki/CA/private/cakey.pem -days 365 -x509 -out /etc/pki/CA/cacert.pem
//產生CA認證機構的自我簽署憑證
//-x509 數位憑證協議
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) []:liaoning
Locality Name (eg, city) [Default City]:shenyang
Organization Name (eg, company) [Default Company Ltd]:uplooking
Organizational Unit Name (eg, section) []:uplooking
Common Name (eg, your name or your server‘s hostname) []:s2.uplooking.com
Email Address []:[email protected]
# openssl ca -in web.csr -out web.crt
Using configuration from /etc/pki/tls/openssl.cnf
/etc/pki/CA/index.txt: No such file or directory
unable to open ‘/etc/pki/CA/index.txt‘
# touch /etc/pki/CA/index.txt //產生CA的索引檔案
# openssl ca -in web.csr -out web.crt
Using configuration from /etc/pki/tls/openssl.cnf
/etc/pki/CA/serial: No such file or directory
error while loading serial number
# echo 01 > /etc/pki/CA/serial //產生CA的序號檔案
----------------------------
產生一個最基本的用來簽發的CA認證機構的步驟
# openssl genrsa 1024 > /etc/pki/CA/private/cakey.pem
//產生CA認證機構所需的私密金鑰
# openssl req -new -key /etc/pki/CA/private/cakey.pem -days 365 -x509 -out /etc/pki/CA/cacert.pem
//產生CA認證機構的自我簽署憑證
# touch /etc/pki/CA/index.txt //產生CA的索引檔案
# echo 01 > /etc/pki/CA/serial //產生CA的序號檔案
-----------------------------
# openssl ca -in web.csr -out web.crt //簽發認證
Using configuration from /etc/pki/tls/openssl.cnf
Check that the request matches the signature
Signature ok
Certificate Details:
Serial Number: 1 (0x1)
Validity
Not Before: Aug 19 01:51:32 2014 GMT
Not After : Aug 19 01:51:32 2015 GMT
Subject:
countryName = CN
stateOrProvinceName = liaoning
organizationName = uplooking
organizationalUnitName = instructor
commonName = s1.uplooking.com
emailAddress = [email protected]
X509v3 extensions:
X509v3 Basic Constraints:
CA:FALSE
Netscape Comment:
OpenSSL Generated Certificate
X509v3 Subject Key Identifier:
7B:E3:E3:19:AF:BD:08:74:A3:49:58:96:4F:BC:82:DF:2B:1A:9 6:06
X509v3 Authority Key Identifier:
keyid:65:48:30:AF:9E:A4:45:33:ED:E6:7C:9F:CD:C7:82:C8:B 1:7D:7E:C4
Certificate is to be certified until Aug 19 01:51:32 2015 GMT (365 days )
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
#scp /root/web.crt s1:/root
---web伺服器---
#yum install mod_ssl -y
# ls web.*
web.crt web.csr web.key
認證 簽章要求 私密金鑰
# vi /etc/httpd/conf.d/ssl.conf
-------------------------
105 SSLCertificateFile /etc/pki/tls/certs/web.crt
112 SSLCertificateKeyFile /etc/pki/tls/private/web.key
-------------------------
#
# cp web.crt /etc/pki/tls/certs/
# cp web.key /etc/pki/tls/private/
# service httpd restart
# netstat -antulp | grep :443
使用瀏覽器訪問你的https的網站
將CA的認證匯入到IE瀏覽器中,然後查看網頁
---CA伺服器---
# yum install vsftpd -y
# service vsftpd start
# cp /etc/pki/CA/cacert.pem /var/ftp/pub/s2CA.crt
用戶端下載s2CA.crt認證
下載完成以後,匯入認證
web伺服器/CA認證機構/用戶端訪問