码迷,mamicode.com
首页 > Web开发 > 详细

OpenSSl生成SSL证书(支持https)

时间:2018-05-24 21:17:12      阅读:445      评论:0      收藏:0      [点我收藏+]

标签:https   openssl   

一:环境与安装说明

     WIN7_64,Nginx服务器,OpenSSL_Win64。本人使用phpStudy集成开发环境,使用Nginx+PHP,支持浏览器https请求。

     nginx下载地址:http://nginx.org/en/download.html 
     openssl下载地址:http://slproweb.com/products/Win32OpenSSL.html 
     官网地址:https://www.openssl.org/source/


二:安装OpenSSL及配置

    1>下载后双击安装,默认安装路径是C:\OpenSSL-Win64

    2>配置环境变量,这里不细说,略过。

    

三:生成ssl证书

   1>首先,无论是在Linux下还是在Windows下的Cygwin中,进行下面的操作前都须确认已安装OpenSSL软件包。

   2>创建根证书密钥文件myopenssl.key,输入以下命令:  openssl genrsa -des3 -out myopenssl.key

       技术分享图片

      这里会提示让输入两次密码,请保持两次密码一致

      Enter pass phrase for root.key: ← 输入一个新密码 
      Verifying – Enter pass phrase for root.key: ← 重新输入一遍密码

   3>创建根证书的申请文件myopenssl.csr,输入以下命令: openssl req -new -key myopenssl.key -out myopenssl.csr

      技术分享图片

      以下是提示信息  

        Enter pass phrase for root.key: ← 输入前面创建的密码 
        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 ← 国家代号,中国输入CN 
        State or Province Name (full name) [Some-State]:BeiJing ← 省的全名,拼音 
        Locality Name (eg, city) []:BeiJing ← 市的全名,拼音 
        Organization Name (eg, company) [Internet Widgits Pty Ltd]:MyCompany Corp. ← 公司英文名 
        Organizational Unit Name (eg, section) []: ← 可以不输入 
        Common Name (eg, YOUR name) []: ← 此时不输入 
        Email Address []:admin@mycompany.com ← 电子邮箱,可随意填

        Please enter the following ‘extra’ attributes 
        to be sent with your certificate request 
        A challenge password []: ← 可以不输入 
        An optional company name []: ← 可以不输入

    4>创建一个自当前日期起为期十年的根证书myopenssl.crt,输入以下命令:openssl x509 -req -days 3650 -sha1 -extensions v3_ca -signkey myopenssl.key -in myopenssl.csr -out myopenssl.crt

     技术分享图片

      以下是提示信息:

     Enter pass phrase for root.key: ← 输入前面创建的密码


OpenSSl生成SSL证书(支持https)

标签:https   openssl   

原文地址:http://blog.51cto.com/shhlamp/2120022

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!