案例应用1:Web服务器架构之https自签发
1.企业实现要求:
某公司要求在Linux上实现web服务器功能,并要求实现自签发证书(及要求:linux服务器即为web服务器又为证书服务器)
2.案例应用简化拓扑图:
3.案例实现步骤:
(1)在web服务器上安装相应的软件
[root@www ~]# mkdir /mnt/cdrom
[root@www ~]# mount /dev/cdrom /mnt/cdrom/
[root@www ~]# cd /mnt/cdrom/Server/
[root@www Server]# rpm -ivh httpd-2.2.3-22.el5.i386.rpm
[root@www ~]# yum install -y mod_ssl
(2)创建CA证书服务器的根证书文件
[root@www ~]# cd /etc/pki/
[root@www pki]# vim tls/openssl.cnf
45 dir =/etc/pki/CA # Where everything is kept
46 certs = $dir/certs # Where the issued certs are kept
47 crl_dir = $dir/crl # Where the issued crl are ke pt
48 database = $dir/index.txt # database index file.
51 new_certs_dir = $dir/newcerts # default place for new certs
53 certificate = $dir/cacert.pem # The CA certificate
54 serial = $dir/serial # The current serial number
58 private_key = $dir/private/cakey.pem# The private key
88 countryName = optional
89 stateOrProvinceName = optional
90 organizationName = optional
[root@www pki]# cd /etc/pki/CA/
[root@www CA]# mkdir certs crl newcerts
[root@www CA]# touch index.txt serial
[root@www CA]# echo "01" >serial
[root@www CA]# openssl genrsa 1024 >private/cakey.pem
Generating RSA private key, 1024 bit long modulus
........................++++++
....++++++
e is 65537 (0x10001)
[root@www CA]# chmod 600 private/cakey.pem
[root@www CA]# openssl req -new -x509 -key private/cakey.pem -out cacert.pem -days 365
Country Name (2 letter code) [GB]:CN
State or Province Name (full name) [Berkshire]:HENAN
Locality Name (eg, city) [Newbury]:ZHENGZHOU
Organization Name (eg, company) [My Company Ltd]:zzu
Organizational Unit Name (eg, section) []:junjie
Common Name (eg, your name or your server's hostname) []:rootca.junjie.com
Email Address []:master@junjie.com
(3)为web服务器的签发证书
[root@www CA]# mkdir /etc/httpd/certs
[root@www CA]#cd /etc/httpd/certs
[root@www certs]# openssl genrsa 1024 >httpd.key
Generating RSA private key, 1024 bit long modulus
..............++++++
........++++++
e is 65537 (0x10001)
[root@www certs]# chmod 600 httpd.key
[root@www certs]# openssl req -new -key httpd.key -out httpd.csr
Country Name (2 letter code) [GB]:CN
State or Province Name (full name) [Berkshire]:HENAN
Locality Name (eg, city) [Newbury]:ZHENGZHOU
Organization Name (eg, company) [My Company Ltd]:zzu
Organizational Unit Name (eg, section) []:junjie
Common Name (eg, your name or your server's hostname) []:
///
[root@www certs]# openssl ca -in httpd.csr -out httpd.crt
[root@www certs]# chmod 600 *
(4)为web服务器的签发证书
[root@www certs]# cd /etc/httpd/conf.d
[root@www conf.d]# vim ssl.conf
112 SSLCertificateFile /etc/httpd/certs/httpd.crt
119 SSLCertificateKeyFile /etc/httpd/certs/httpd.key
128 SSLCertificateChainFile /etc/pki/CA/cacert.pem
(5)win7客户端使用https安全访问网页
[root@www ~]# service httpd restart #重启apache服务
Win7客户端测试在C:\Windows\System32\drivers\etc\hosts添加:
192.168.101.250
使用win7的IE9测试,输入安全网址https://www.junjie.com
,此时浏览器提示安全警告,提示此网站的安全证书有问题,并将警告信息显示出来,具体如下:
如若:用户强制继续访问,侧依然可以访问,但是浏览器地址栏中,已经变成红色报警信息,提示此网站不安全
说明:在此由于我没有使用IE9浏览器,没有解决证书问题,故又使用搜狗浏览器来解决证书错误问题!若,你可以帮助我解决请在本文留言,多谢了!
使用搜狗解决问题方案如下:
此时,选择查看证书-证书路径-查看安装根证书和web服务器证书
安装证书;
选择是继续安装证书,接着再查看就没有证书问题了,如下所示:
此时再win7下使用搜狗高速浏览器,Internet Explorer 9浏览器,都显示安全访问,如下所示:
查看证书信息: