(1)安裝mod_ssl [root@nan83 html]# yum list|grep mod_ssl mod_ssl.x86_64 [root@nan83 html]# yum install mod_ssl.x86_64 (2)建立CA證書 //建立rsa私用密鑰 [root@nan83 ~]# cd /etc/pki/tls/certs --密鑰文件的存放地方 [root@nan83 certs]# make beer.key --創建Apache使用的私鑰文件 umask 77 ; \ /usr/bin/openssl genrsa -aes128 2048 > beer.key --其實使用的是這句建立語句 Generating RSA private key, 2048 bit long modulus .........................................................+++ ..................................................+++ e is 65537 (0x10001) Enter pass phrase: Verifying - Enter pass phrase: 或使用下面語句建立: openssl genrsa -des3 -out beer.key 1024 //查看beer.key內容 [root@nan83 certs]# openssl rsa -noout -text -in beer.key (3)將建立的文件中的密碼取消掉,不要密碼存在 [root@nan83 certs]# mv beer.key beer.key.raw [root@nan83 certs]# openssl rsa -in beer.key.raw -out beer.key Enter pass phrase for beer.key.raw: writing RSA key [root@nan83 certs]# rm -f beer.key.raw [root@nan83 certs]# chmod 400 beer.key (4)創建所須要的最終文件 //利用CA的RSA密鑰建立一個自簽署的CA證書 [root@nan83 certs]# make beer.crt SERIAL=2014030601 umask 77 ; \ /usr/bin/openssl req -utf8 -new -key beer.key -x509 -days 365 -out beer.crt -set_serial 2014030601 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) []:HeNan Locality Name (eg, city) [Default City]:LuoYang Organization Name (eg, company) [Default Company Ltd]:ShiWei Organizational Unit Name (eg, section) []:RuanJian Common Name (eg, your name or your server's hostname) []:Lsn Email Address []:lisn@ssr.com [root@nan83 certs]# chmod 400 beer* [root@nan83 certs]# ll beer* -r-------- 1 root root 1375 3月 6 09:16 beer.crt --最終證書文件 -r-------- 1 root root 1679 3月 6 09:09 beer.key --系統私鑰文件 (5)修改ssl.cof的內容,使用自制證書 [root@nan83 certs]# vim /etc/httpd/conf.d/ssl.conf SSLCertificateFile /etc/pki/tls/certs/beer.crt SSLCertificateKeyFile /etc/pki/tls/certs/beer.key 測試: 在瀏覽器裏輸入「https://10.10.54.83」