社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  NGINX

Nginx双证书ECC\/RSA配置

黑白之道 • 8 年前 • 1422 次点击  


大家好,我是你们的老朋友Alex。今天教大家使用nginx配置证书,双证书!

Nginx1.11.0版本后提供了ESA/ECC双证书的支持,以下是参考链接:

https://www.mf8.biz/ecc-nginx-double-cert

http://www.freebuf.com/articles/database/155912.html

ECDSA (椭圆曲线数字签名算法) 就是我们所说的 ECC 证书了,相比 RSA, ECC 证书具有安全性高, 处理速度更快的优点,尤其适合在移动设备上使用。但是其唯一的缺点就是兼容性问题,古代的 XP 和 Android2.3 不支持这种加密方式。

于是双证书就出现了,它可以在 TLS 握手的时候根据客户端支持的加密方法选择对应的证书, 以向下兼容古代客户端。


首先更新我们的openssl更新到1.0.2h,避免CVE-2016-2107 的影响

wget https://github.com/openssl/openssl/archive/OpenSSL_1_0_2h.tar.gz

tar -zxvf OpenSSL_1_0_2h.tar.gz

cd openssl-OpenSSL_1_0_2h/

./config --prefix=/usr/local --openssldir=/usr/local/openssl

Make

Make test

Make install

mv /usr/bin/openssl /usr/bin/openssl.bak

mv /usr/include/openssl /usr/include/openssl.bak

ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl

ln -s /usr/local/ssl/include/openssl /usr/include/openssl

echo “/usr/local/ssl/lib” >> /etc/ld.so.conf

ldconfig –v


之后查看当前版本


openssl version –a


安装nginx,我选择的是1.11.1版本

wget http://nginx.org/download/nginx-1.11.1.tar.gz

tar -zxvf nginx-1.11.1.tar.gz

如果有需要安装ct模块的同学,请下载

wget -O nginx-ct.zip -c https://github.com/grahamedgecombe/nginx-ct/archive/v1.3.2.zip

cd nginx-1.11.1/

./configure --prefix=/usr/share/nginx--conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log--error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock--pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body--http-fastcgi-temp-path=/var/lib/nginx/fastcgi--http-proxy-temp-path=/var/lib/nginx/proxy--http-scgi-temp-path=/var/lib/nginx/scgi--http-uwsgi-temp-path=/var/lib/nginx/uwsgi --add-module=../nginx-ct-1.2.0--with-openssl=../OpenSSL_1_0_2h --with-http_v2_module --with-http_ssl_module

#这里的--with-openssl=../OpenSSL_1_0_2h指定之前安装的openssl文件夹

Make

Make install


之后申请证书的问题,就用下面两个链接处脚本即可!具体方法请大家百度

https://github.com/Neilpang/acme.sh

https://github.com/certbot/certbot

~/.acme.sh/acme.sh --issue -d 域名 --standalone-k ec-256

~/.acme.sh/acme.sh --issue -d 域名 --standalone-k 3072

申请到两个证书分别为ECC和RSA,可惜只有90天有效期,大家90天后再续期就可以了!

我们继续编辑nginx.conf配置文件

ssl_certificate和ssl_certificate_key分别放入两个证书文件以及密钥,

使用openssl dhparam -out dhparam.pem 4096生成4096位DH-Key,在conf文件中使用ssl_dhparam指定证书密钥交换密钥即可!

ssl_prefer_server_ciphers  on指定优先采取服务器算法,如果需要启用ct使用以下

ssl_ct on;

ssl_ct_static_scts /path/to/sct/dir;

最后配置我们的自定义算法

ssl_ciphers处大家使用openssl验证,来确定优先使用哪种证书验证


openssl ciphers -V 'EECDH CHACHA20:EECDH CHACHA20-draft:EECDH AES128:RSA AES128:EECDH AES256:RSA AES256:EECDH 3DES:RSA 3DES:!MD5'| column –t

我的第一选择为RSA,具体还要其他算法,下面只是一些例子

链接:https://maoxian.de/2016/08/1436.html


我们以配置文件启动nginx即可

/usr/local/nginx/sbin/nginx -c/usr/local/nginx/conf/nginx.conf


我们可以使用以下链接验证我们网站目前SSL的状态

https://www.ssllabs.com/ssltest/index.html

https://myssl.com/

(o゜▽゜)o☆[BINGO!]

你会喜欢


XenServer的安装配置

vsftpd服务器的后续配置

NFS服务器的安装配置



今天看啥 - 高品质阅读平台
本文地址:http://www.jintiankansha.me/t/sjFK2TknsS
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/4692