国密 SM2 SSL 证书 Nginx 安装指南 linux版

一、获取国密证书

1、在您完成申请西部GDCA服务器证书的流程后,下载证书将获取一个证书包,有以下

*.***.com_sign.crt:签名证书

*.***.com_sign.key:签名证书私钥

*.***.com_encrypt.crt:加密证书

*.***.com_encryptKeyData.txt:内容为已加密的加密证书私钥片段

2、加密证书解密

在线解密:私钥加解密

创建 *.**.com_encrypt.key 文件,将获取的解密后 解密证书私钥 内容填写进去。

二、部署国密nginx

国密OpenSSL与国密Nginx

gmssl_openssl_1.1_bxx.tar.gz

无缝nginx国密改造,支持nginx1.6+

编译部署(以nginx-1.18.0为例)

  1. 下载 wget http://download.myhostadmin.net/gmssl/gmssl_openssl_1.1_b8.tar.gz到/root/下

  2. 解压 tar xzfm gmssl_openssl_1.1_b8.tar.gz -C /usr/local

  3. 下载wget http://download.myhostadmin.net/gmssl/nginx-1.18.0.zip 到/root/下

  4. 解压 unzip nginx-1.18.0.zip

注:可能需要使用yum install pcre-devel需要安装pcre-devel

  1. 进入目录 cd /root/nginx-1.18.0

  2. 编译配置

./configure \

--without-http_gzip_module \

--with-http_ssl_module \

--with-http_stub_status_module \

--with-http_v2_module \

--with-file-aio \

--with-openssl="/usr/local/gmssl" \

--with-cc-opt="-I/usr/local/gmssl/include" \

--with-ld-opt="-lm"

  1. 编译安装

make install

  1. /usr/local/nginx即为生成的nginx目录

9)编译安装完成后,cd 进入/usr/local/nginx/sbin 目录,用 ./nginx -t 命令检测是否正常,如下:

配置示例(国密单向)

*.***.com_sign.crt:签名证书

*.***.com_sign.key:签名证书私钥

*.***.com_encrypt.crt:加密证书

*.***.com_encrypt.key : 加密证书私钥

server

{

listen 0.0.0.0:443 ssl;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:AES128-SHA:DES-CBC3-SHA:ECC-SM4-CBC-SM3:ECC-SM4-GCM-SM3;

ssl_verify_client off;

ssl_certificate /usr/local/nginx/conf/*.***.com_sign.crt;

ssl_certificate_key /usr/local/nginx/conf/*.***.com_sign.key;

ssl_certificate /usr/local/nginx/conf/*.***.com_encrypt.crt;

ssl_certificate_key /usr/local/nginx/conf/*.***.com_encrypt.key;

location /

{

root html;

index index.html index.htm;

}

}

配置示例(国密/RSA单向自适应)

server

{

listen 0.0.0.0:443 ssl;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:AES128-SHA:DES-CBC3-SHA:ECC-SM4-CBC-SM3:ECC-SM4-GCM-SM3;

ssl_verify_client off;

ssl_certificate /usr/local/nginx/conf/*.***.com.crt;

ssl_certificate_key /usr/local/nginx/conf/*.***.com.key;

ssl_certificate /usr/local/nginx/conf/*.***.com_sign.crt;

ssl_certificate_key /usr/local/nginx/conf/*.***.com_sign.key;

ssl_certificate /usr/local/nginx/conf/*.***.com_encrypt.crt;

ssl_certificate_key /usr/local/nginx/conf/*.***.com_encrypt.key; location /

{

root html;

index index.html index.htm;

}

}

测试配置是否正确/usr/local/nginx/sbin/nginx -t

启动/usr/local/nginx/sbin/nginx

三、访问测试

1、360企业浏览器 设置,打开浏览器点击右上角的

按钮-》"选项"-》"安全设置",确保"国密通信协议"栏目已勾选

"启用国密SSL协议支持"的复选框,如下:

访问效果示例:

原文链接:https://www.west.cn/faq/list.asp?unid=2513

相关推荐
Darkwanderor5 分钟前
Linux 的权限详解
linux
SabreWulf202034 分钟前
Ubuntu 20.04手动安装.NET 8 SDK
linux·ubuntu·avalonia·.net8
不是吧这都有重名36 分钟前
为什么ubuntu大文件拷贝会先快后慢?
linux·运维·ubuntu
sunshine-sm1 小时前
CentOS Steam 9安装 Redis
linux·运维·服务器·redis·centos
小熊h1 小时前
MySQL集群高可用架构——组复制 (MGR)
linux·数据库·mysql
提笔忘字的帝国2 小时前
宝塔SSL自动续签
网络·网络协议·ssl
棒棒的唐2 小时前
armbian平台ubuntu环境下telnet安装及启动,给pantherX2增加一个应急通道
linux·运维·armbian·telnetd
bug攻城狮2 小时前
CentOS 7 设置静态 IP 地址
linux·tcp/ip·centos
纳切威2 小时前
CentOS 7部署Zabbix5.0
linux·运维·centos·zabbix
sunshine-sm2 小时前
CentOS Steam 9安装 MySQL 8
linux·运维·服务器·数据库·mysql·centos·centos stream