服务器配置openssl支持 https 访问

 

一、Windows + apache 下,  软件是xampp

  说明:部分参考(http://blog.sina.com.cn/s/blog_5d7dbbdd0101042n.html

  首先要载入 mod_ssl 。

 

  1. 将证书生成的配置文件(http://tud.at/programm/openssl.cnf) 复制到 apache/bin/openssl.cnf

  2. cmd进入apache/bin目录(必须是 openssl.exe 所在目录)。  使用命令生成

    openssl req -config ./openssl.cnf -new-out server.csr  

   ## 逐次填写信息

    openssl rsa -in privkey.pem -out server.key   

    openssl x509 -in server.csr -out server.crt -req -signkey server.key  

     openssl req -x509 -days 730 -key server.key -in server.csr > server.crt 

   或,版本较新可以使用这个
     set openssl_conf=./openssl.cnf 
     openssl genrsa 4096 -des3 > server.key 
     openssl req -new -key server.key > server.csr 
  
 
  
set openssl_conf=./openssl.cnf
   openssl req -nodes -newkey rsa:2048 -keyout server.key -out server.csr
   ## 加 -nodes 的作用: key 将不会用DES 加密字符加密, ————这在windows上可能非常重要,win上可能会有一个启动错误 SSLPassPhraseDialog  builtin 。
  
 ## 逐次填写内容. 设密码。
    

  3.这当前进入的目录(***apache/bin)生成了几个文件, 将 server.key, server.crt 复制到

    apache/conf/ssl.crt/example.crt

    apache/conf/ssl.key/example.key

    ##  重命名,是在有多个虚拟主机时名字不重复

 

  4. 依照示例配置 http-ssl.conf.

    <VirtualHost  *:443>

                 SSLEngine on
      ServerName example.com:443

                 DocumentRoot "E:/www/example.com"

      #ServerAdmin webadmin@example.com

      #ErrorLog "logs/error.log"

      SSLCertificateFile "E:/mySoft/xampp/apache/conf/ssl.crt/example.crt"
      SSLCertificateKeyFile "E:/mySoft/xampp/apache/conf/ssl.key/example.key"


      <IfModule log_config_module>
        CustomLog "logs/access.log" combined
      </IfModule>


      <Files ~"\.(cgi|shtml|phtml|php|htm|html?)$>
        SSLOptions +StdEnvVars
      </Files>


    </VirtualHost>

    其他参数和80端口一样就行。Files匹配 参数见说明 http://httpd.apache.org/docs/2.0/mod/mod_ssl.html#ssloptions

  可能遇到的错误: 

  [warn] Init: (23.234.16.94:443) You configured HTTP(80) on the standard HTTPS(443) port!

  解决:  SSLEngine on

   自动跳转到第一个vhost:

    <Virtualhost *:443> 之前加个 NameVirtualHost *:443   

 

  题外话:

    其实自己生成的证书没什么意义,仅供本地开发。 当然,有很多卖证书的网站,使用上面手动生成的 csr 文本内容生成 crt(sha1或sha2加密在这一步设定)。

        VeriSign的过于昂贵,最便宜的要 2000一年。我申请了 startSsl.com 的免费版,当然它的基础付费版也才 $49一年,坑爹的是如果你要删除这个域名,需要付$24美元。最后

      我搞了个 Comodo.com 的, $64.99/年,可以试用90天,很好。

  

  另外一个问题是, 如果你的运行系统是 windows xp sp2 以下, 并不支持sha2加密的,可以使用sha1加密,或者下载补丁 (官方补丁下载)

 

Linux记录暂无, 其实基本一样。

 

转载于:https://www.cnblogs.com/antarctican/p/4037945.html

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值