Chinaunix首页 | 论坛 | 博客
  • 博客访问: 286402
  • 博文数量: 87
  • 博客积分: 1206
  • 博客等级: 少尉
  • 技术积分: 725
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-16 00:12
个人简介

do the right things the right ways

文章分类

全部博文(87)

文章存档

2017年(5)

2016年(6)

2015年(1)

2012年(11)

2011年(64)

分类: LINUX

2011-12-19 17:11:59

为了解决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) []:station5@example.com
  Email Address []:root@example.com
  #建立网站证书文件,在建立时需要输入相关信息,重点在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文件
              #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    #指定私钥文件
  

  4.重启服务后测试
  [root@station5 ~]# /etc/init.d/httpd restart
阅读(1261) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~