国密 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

相关推荐
bosins3 小时前
WSL2 启动即崩溃?调整超时参数解决 Docker 阻塞问题
linux·docker·wsl
web守墓人4 小时前
【goed/ui】自定义组件设计思想篇
linux·windows·ui·golang
kuroomi4 小时前
Ingress-Nginx与kubernetes 网络
linux·运维·网络·kubernetes
daemon.qiang4 小时前
国内虚拟机对接 Freedesktop:Fork xserver、自建 Runner 与提交 MR 实战
linux·ubuntu·centos·gitlab·开源软件
2401_869769596 小时前
linux 权限 指令与权限(重启之后)
linux
码农客栈6 小时前
Linux CAN 驱动
linux·驱动开发
打工仔折腾 AI7 小时前
FastAPI 从本机到生产服务器:Nginx+Gunicorn+Uvicorn 完整部署实录
人工智能·后端·python·nginx·fastapi·gunicorn
GeW8 小时前
红帽RHCE从挂科边缘到一次过,我做对了什么
linux
时空自由民.8 小时前
WSL解决USB 串口连接问题与linux串口权限问题
linux·单片机
OpenPomeloxCommunity8 小时前
Linux驱动基础(三):firmware的声明与加载
linux·操作系统