zoukankan      html  css  js  c++  java
  • 基于nginx结合openssl实现https

    [root@localhost ~]#systemctl stop firewalld
    [root@localhost ~]#setenforce 0
    [root@localhost ~]#iptables -F
    [root@localhost ~]#yum -y install pcre zlib openssl openssl-devel pcre-devel zlib-devel
    [root@localhost ~]#cd /usr/local/nginx-1.16.0
    [root@localhost nginx-1.16.0]#./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module
    [root@localhost ~]#make && make install
    [root@localhost ~]#useradd -M -s /sbin/nologin nginx
    [root@localhost ~]#ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin
    [root@localhost ~]#nginx
    [root@localhost ~]# touch /etc/pki/CA/index.txt
    [root@localhost ~]# echo 01 > /etc/pki/CA/serial
    [root@localhost ~]# cd /etc/pki/CA/
    [root@localhost CA]# umask 066
    [root@localhost CA]# openssl genrsa -out /etc/pki/CA/private/cakey.pem 2048
    [root@localhost ~]# openssl req -x509 -key /etc/pki/CA/private/cakey.pem -days 7300 -out /etc/pki/CA/cacert.pem
    Country Name (2 letter code) [XX]:CN
    State or Province Name (full name) []:BJ
    Locality Name (eg, city) [Default City]:BJ
    Organization Name (eg, company) [Default Company Ltd]:WXYC
    Organizational Unit Name (eg, section) []:JSB
    Common Name (eg, your name or your server's hostname) []:a.com
    Email Address []:111111@sina.com

    [root@localhost ~]# mkdir key
    [root@localhost ~]# cd key/
    [root@localhost key]# umask 066
    [root@localhost key]# openssl genrsa -out service.key 2048
    [root@localhost key]# openssl req -new -key service.key -out service.csr
    Country Name (2 letter code) [XX]:CN
    State or Province Name (full name) []:BJ
    Locality Name (eg, city) [Default City]:BJ
    Organization Name (eg, company) [Default Company Ltd]:WXYC
    Organizational Unit Name (eg, section) []:JSB
    Common Name (eg, your name or your server's hostname) []:a.com
    Email Address []:111111@sina.com

    Please enter the following 'extra' attributes
    to be sent with your certificate request
    A challenge password []:
    An optional company name []:

    [root@localhost key]# mkdir /etc/pki/CA/csr
    [root@localhost key]# mv service.csr /etc/pki/CA/csr
    [root@localhost key]# openssl ca -in /etc/pki/CA/csr/service.csr -out /etc/pki/CA/certs/service.crt -days 365
    Sign the certificate? [y/n]:y


    1 out of 1 certificate requests certified, commit? [y/n]y

  • 相关阅读:
    字符串系列——Immediate Decodability
    Java I/O流操作(四)对象的序列化
    table自动拉伸在chrome与IE中的区别
    【web开发】spring+hibernate4支持中文排序
    SQL批量重命名中文字段名为对应拼音首字母字段名脚本
    Hibernate执行查询后又立马执行了更新(defaultaccess)
    上传图片之上传前预览图片
    挖掘FPTree
    Linux下Json库的编译及代码测试
    C语言中的位运算和逻辑运算
  • 原文地址:https://www.cnblogs.com/lyqlyqlyq/p/11641737.html
Copyright © 2011-2022 走看看