zoukankan      html  css  js  c++  java
  • wamp openssl

    在这一章节里, 我记录了一下如何在 wamp 环境下配置 ssl

    前提条件

    在设置 Apache + SSL 之前, 需要确认 Apache 已经安装并可以正常工作. 并且 ssl 需要的文件在如下的位置:

    1
    2
    3
    4
    5
    [Apache安装目录]/modules/ mod_ssl.so
     
    [Apache安装目录]/bin/ openssl.exe, libeay32.dll, ssleay32.dll
     
    [Apache安装目录]/conf/ openssl.cnf

    配置文件修改

    1
    2
    3
    //去掉下面行首的 # 号
    #LoadModule ssl_module modules/mod_ssl.so
    #Include conf/extra/httpd-ssl.conf

    用于载入 ssl 模块和其配置文件

    认证文件生成

    在命令行下进入Apache安装目录下in文件夹,输入命令:

    1
    2
    3
    //生成证书签发请求
     
    D:wampapachein> openssl req -new -out server.csr -config ../conf/openssl.cnf
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    //回车后要求输入密码和确认密码
     
    Loading 'screen' into random state - done
    Generating a 1024 bit RSA private key
    ......................................................................++++++
    ........................................++++++
    writing new private key to 'privkey.pem'
    Enter PEM pass phrase: 123456
    Verifying - Enter PEM pass phrase: 123456
    -----
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    //确认密码输完回车后, 要求输入国家缩写, 只能2个字母
     
    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) [AU]:CN
    1
    2
    3
    //要求输入州名或省名
     
    State or Province Name (full name) [Some-State]:Shanghai
    1
    2
    3
    //要求输入城市名
     
    Locality Name (eg, city) []:Shanghai
    1
    2
    3
    //要求输入组织名或者公司名
     
    Organization Name (eg, company) [Internet Widgits Pty Ltd]:yiban
    1
    2
    3
    //要求输入部门名
     
    Organizational Unit Name (eg, section) []:yiban
    1
    2
    3
    //要求输入服务器域名或IP地址
     
    Common Name (e.g. server FQDN or YOUR name) []:yiban
    1
    2
    3
    //要求输入邮件地址
     
    Email Address []:shawn0828@hotmail.com
    1
    2
    3
    4
    5
    //要求输入密码
     
    Please enter the following 'extra' attributes
    to be sent with your certificate request
    A challenge password []:123456
    1
    2
    3
    //要求输入公司别名
     
    An optional company name []:yiban
    1
    2
    3
    //生成私钥,输入命令:
     
    D:wampapachein>openssl rsa -in privkey.pem -out server.key
    1
    2
    3
    4
    //要求输入之前 privkey.pem 的密码
     
    Enter pass phrase for privkey.pem: 123456
    writing RSA key
    1
    2
    3
    //创建证书,输入命令:
     
    D:wampapachein>openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 8000
    1
    2
    3
    4
    5
    6
    7
    //回车后, 显示创建成功, 有效期为 8000 天
     
    Loading 'screen' into random state - done
    Signature ok
    subject=/C=CN/ST=Shanghai/L=Shanghai/O=yiban/OU=yiban/CN=yiban/emailAddress=shaw
    n0828@hotmail.com
    Getting Private key

    完成后, 将 in 下面的 server.csr、server.crt、server.key 拷贝到 [Apache安装目录]confssl 文件夹中, 没有则创建

    再打开 [Apache安装目录]confextrahttpd-ssl.conf 文件
    替换 SSLCertificateFile 和 SSLCertificateKeyFile 语句对应的路径,例:

    1
    2
    3
    4
    #SSLCertificateFile "D:/wamp/apache/conf/server.crt" //配置文件默认内容
     
    //替换为
    SSLCertificateFile "D:/wamp/apache/conf/ssl/server.crt"
    1
    2
    3
    4
    #SSLCertificateKeyFile "D:/wamp/apache/conf/server.key" //配置文件默认内容
     
    //替换为
    SSLCertificateKeyFile "D:/wamp/apache/conf/ssl/server.key"

    最后, 重启 Apache 服务器

    2013的某一天

    在重启 Apache 时,若遇到 Apache 无法运行的情况

    1
    2
    可以运行开始菜单中 Apache HTTP Server 2.2Configure Apache ServerTest Configuration
    来查找 httpd.conf 中的详细错误情况
    1
    或通过查看 Apache 安装目录下的 logs 文件夹内的 access.log 和 error.log 中的记录解决问题

    如有更好的建议和代码片段,欢迎留言提出

  • 相关阅读:
    java从基础知识(九)I/O
    c++学习笔记(2)类的声名与实现的分离及内联函数
    转:给C++初学者的50个忠告
    c++学习(1)
    vim下缩进及高亮设置
    转载:c++ sort用法
    菜鸟成长记1,软件工程大一经历
    linux下挂载另一系统硬盘。
    OpenCV VideoCapture.get()参数详解
    opencv+python 添加文字 cv2.putText
  • 原文地址:https://www.cnblogs.com/liuwenbohhh/p/4425425.html
Copyright © 2011-2022 走看看