首页 电脑 电脑学堂 查看内容

Apache建立SSL网站练习

2011-9-15 21:42 579 0

摘要:   为了解决HTTP传输协议的安全性,使用客户端与服务器之间使用加密传输。这个传输的方式有点  像SSH联机方式,通过Public Key与Private Key 这一对Key Pair来加解密。  ...
关键词: nbsp station 文件 sslkey Name httpd root Key 证书 server

  为了解决HTTP传输协议的安全性,使用客户端与服务器之间使用加密传输。这个传输的方式有点  像SSH联机方式,通过Public Key与Private Key 这一对Key Pair来加解密。  由于是测试使用,所以证书不用通过CA认证。  HTTPS配置  1.Apache 实现HTTPS需要安装mod_ssl模块  [root@station5 ~]# yum -y install mod_ssl  2.向自己发证书  [root@station5 ~]# mkdir /etc/httpd/.sslkey/  [root@station5 ~]# cd /etc/httpd/.sslkey/        #建立存放证书目录  [root@station5 .sslkey]# openssl genrsa -out server.key 1024   #建立网站私钥文件  [root@station5 .sslkey]# openssl req -new -x509 -key server.key -out server.crt  Country Name (2 letter code) [GB]:CN  State or Province Name (full name) [Berkshire]:guangdong  Locality Name (eg, city) [Newbury]:dongguan  Organization Name (eg, company) [My Company Ltd]:IT  Organizational Unit Name (eg, section) []:baidu.com  Common Name (eg, your name or your server's hostname) []:[email protected]  Email Address []:[email protected]  #建立网站证书文件,在建立时需要输入相关信息,重点在Common Name 必须是客户端访问  网站时的FQDN  注:建立Public Key说明  [root@station5 .sslkey]# openssl [操作] -out filename [bits]  操作:主要有以下两个  genrsa,建立RSA加密的public key  req,建立凭证要求文件或者是凭证文件  -out :后面加上输出的key文件名  bits:用在genrsa加密公钥长度  -x509: 一种验证管理方式  3.设置Apache的支持  安装mod_ssl之后,将提供 /etc/httpd/conf.d/ssl.conf,可以直接修改这个文件,Apache会自动加载/etc/httpd/conf.d的  conf文件  <VirtualHost 192.168.0.5:443>            #https侦听端口443  DocumentRoot /var/www/html/station5        #网站目录  ServerName station5.example.com        #访问域名  SSLEngine on                   #开启SSL  sslcertificatefile /etc/httpd/.sslkey/server.crt    #指定证书文件  sslcertificatekeyfile /etc/httpd/.sslkey/server.key    #指定私钥文件  </VirtualHost>  4.重启服务后测试  [root@station5 ~]# /etc/init.d/httpd restart
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系 [邮箱地址] 删除

路过

雷人

握手

鲜花

鸡蛋

最新评论

返回顶部