zoukankan      html  css  js  c++  java
  • 制作私有ssl证书

    1.编译安装nginx

    安装前准备:

    service iptables stop

    setenforce 0

    yum -y install pcre-devel zlib-devel

    useradd -M -s /sbin/nologin nginx

    上传nginx源码包后

    tar xf nginx-1.6.2.tar.gz -C /usr/src/

    cd /usr/src/nginx-1.6.2/

    ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module && make && make install   //编译时加入--with-http_ssl_module参数

    设置软链接

    ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/

    2.生成证书

    进入创建证书和私钥的目录

    cd /usr/local/nginx/conf/

    创建服务器私钥,回车后会让你输入一个口令:

    openssl genrsa -des3 -out server.key 1024

    创建签名请求的证书(CSR):

    openssl req -new -key server.key -out server.csr

    回车后出现以下选项:(除了填写域名,其他都可以直接回车跳过)

    Country Name (2 letter code) [XX]:    ///国家

    State or Province Name (full name) []:   ///省份

    Locality Name (eg, city) [Default City]:   ///城市

    Organization Name (eg, company) [Default Company Ltd]:   ///部门

    Organizational Unit Name (eg, section) []:    ///组织或公司名称

    Common Name (eg, your name or your server's hostname) []:www.benet.com    ///域名

    Email Address []:   ///邮箱

    Please enter the following 'extra' attributes

    to be sent with your certificate request

    A challenge password []:

    An optional company name []:

    在加载SSL支持的Nginx并使用上述私钥时除去必须的口令:

    openssl rsa -in server.key -out server_nopwd.key

    最后标记证书使用上述私钥和CSR:

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

    至此证书生成完毕

    3.配置nging配置文件

    vim nginx.conf

    修改server段加入以下内容:

    server {

            listen       443;

            server_name  localhost;

            ssl on;

            ssl_certificate  /usr/local/nginx/conf/server.crt;

            ssl_certificate_key  /usr/local/nginx/conf/server_nopwd.key;

            charset utf-8;

            location / {

                root   html;

                index  index.html index.htm;

            }

    }

    检查nginx.conf语法是否有错误

    nginx –t

    启动nginx

    nginx

    如果已经启动,就使用killall nginx 命令先杀死nginx进程,然后再重新启动

    4.在客户机上导入证书

    首先把生成的证书传到客户机上

    sz server.crt 192.168.1.104

    在客户机上操作:

    控制面板 -> Internet选项 -> 内容 -> 发行者 -> 受信任的根证书颁发机构 -> 导入 -》选择server.crt

    然后在浏览器上输入https://www.benet.com能够正常访问

  • 相关阅读:
    (转)水经注谷歌地图的级别与对应比例尺及分辨率探究
    oracle 单表导出导入
    案例情景--在一次Oracle 数据库导出时 EXP-00008;ORA-00904:EXP-00000: oracle不同版本导入导出规则
    权衡微服务
    ASP.NET Core HTTP 管道中的那些事儿
    ASP.NET Core 中间件之压缩、缓存
    .NET Core 首例 Office 开源跨平台组件(NPOI Core)
    ASP.NET Core 之 Identity 入门(三)
    Entity Framework Core 1.1 升级通告
    ASP.NET Core 1.1.0 Release Notes
  • 原文地址:https://www.cnblogs.com/litzhiai/p/10906183.html
Copyright © 2011-2022 走看看