概述:在我们通常用“http://”这样的方式来访问网站的时候,传输内容是可能被别人截获的,因为其内容是通过明文传输,所以在传递一些隐私、以及密码相关的信息时,就显得非常的不安全。在一些比较正式的网站、以及一些银行相关的网站中,一些需要提交隐私或者重要级别比较高的密码时,都采用 “https://”的方式,来将传输内容加密,从而保证用户安全和避免隐私的泄漏。
环境:centos5 vps
目的:在vps主机架构一台使用https://ssl.15099.net的主机
步骤:
1)软件环境要求:
在已经架构的LAMP环境上,要使用https加密访问网站,https是利用SSL来加密传输的,利用mod_ssl帮我们制作好key以及凭证,所以需要先确保系统是否已经安装openssl和mod_ssl软件,如没有安装,使用下面命令安装:
# yum -y install openssl mod_ssl
2)建立自认证证书
2-1、生成私有证书:
# openssl genrsa -out ca.key 1024
2-2、建立用于申请的认证文件
[root@www ~]# openssl req -new -key ca.key -out ca.csr
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) [GB]:CN
State or Province Name (full name) [Berkshire]:Guangdong
Locality Name (eg, city) [Newbury]:Guangzhou
Organization Name (eg, company) [My Company Ltd]:vps-hosting
Organizational Unit Name (eg, section) []:vps-hosting
Common Name (eg, your name or your server's hostname) []:ssl.15099.net
Email Address []:vps@15099.net
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
[root@www ~]#
2-3、生成自认证key
openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt
2-4、把生成的文件放置到正确的位置:
# mv ca.crt /etc/pki/tls/certs
# mv ca.key /etc/pki/tls/private/ca.key
# mv ca.csr /etc/pki/tls/private/ca.csr
2-5、 编辑apache SSL配置文件
# vi /etc/httpd/conf.d/ssl.conf
把
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
修改为:
SSLCertificateFile /etc/pki/tls/certs/ca.crt
把
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
修改为:
SSLCertificateKeyFile /etc/pki/tls/private/ca.key
3、设置虚拟主机
# vim /etc/httpd/conf.d/VirtualHost.conf
增加如下内容:
NameVirtualHost *:443
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/ca.crt
SSLCertificateKeyFile /etc/pki/tls/private/ca.key
AllowOverride All
DocumentRoot /var/www/html/ssl.15099.net
ServerName ssl.15099.net
重启apache服务
# apachectl restart
4)建立测试文件
# mkdir /var/www/html/ssl.15099.net
# echo https-test > /var/www/html/ssl.15099.netindex.html
5)测试
在游览器地址栏输入:https://ssl.15099.net就可以访问刚才建立的index.html文件了
没有评论:
发表评论