通过网页查看服务器算法,服务器使用国密(SM2/SM3/SM4)证书,通过浏览器访问
1. Apache + Gmssl
Apache 本身不支持国密,需要修改代码支持GMTLS
下载解压: wget http://archive.apache.org/dist/httpd/httpd-2.4.39.tar.gz
tar -zxf httpd-2.4.39.tar.gz
修改文件:Apache dir\modules\ssl\ssl_engine_init.c
SSL_CTX_set_min_proto_version(ctx, prot);
这一行前增加prot = GMTLS_VERSION;
安装
安装依赖 yum install -y wget gcc gcc-c++ pcre-devel perl
wget http://mirror.bit.edu.cn/apache//apr/apr-1.7.0.tar.gz
tar -zvxf apr-1.7.0.tar.gz
cd apr-1.7.0
./configure --prefix=/usr/local/apr
make -j32 && make install
wget http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz
tar -zvxf apr-util-1.5.4.tar.gz
cd apr-util-1.5.4
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make -j32 && make install
安装gmssl wget https://codeload.github.com/guanzhi/GmSSL/zip/master
unzip GmSSL-master.zip
./config --prefix=/usr/local/gmssl
make -j32 && make install
和gmssl一起编译安装apache ./configure --prefix=/usr/local/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork --with-zlib --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-ssl=/usr/local/gmssl
make -j32 && make install
添加动态链接 vi /etc/ld.so.conf /usr/local/gmssl/lib
ldconfig
使用国密算法生成证书
配置openssl.cnf 文件
使用以下命令生成证书# 生成CA证书
/usr/local/gmssl/bin/gmssl ecparam -genkey -name SM2 -noout -out ca.key
/usr/local/gmssl/bin/gmssl req -new -key ca.key -out ca.req -subj "/C=CN/O=AsiaInfo/OU=CoreTech/CN=Localhost.10.22.2.112"
/usr/local/gmssl/bin/gmssl x509 -req -days 3650 -sm3 -in ca.req -extfile ./openssl.cnf -extensions v3_ca -signkey ca.key -out ca.crt
# Server签名证书
/usr/local/gmssl/bin/openssl ecparam -name SM2 -genkey -noout -out server.key
/usr/local/gmssl/bin/openssl req -new -SM3 -key server.key -out server.csr -subj /C=CN/O=AsiaInfo/OU=CoreTech/CN="10.22.2.112"
/usr/local/gmssl/bin/openssl x509 -req -SM3 -days 3650 -in server.csr -extfile ./openssl.cnf -extensions v3_req -CA ca.crt -CAkey ca.key -set_serial 1000000001 -out server.crt
# Server加密证书
/usr/local/gmssl/bin/openssl ecparam -name SM2 -genkey -noout -out server_en.key
/usr/local/gmssl/bin/openssl req -new -SM3 -key server_en.key -out server1.csr -subj /C=CN/O=AsiaInfo/OU=CoreTech/CN="10.22.2.112"
/usr/local/gmssl/bin/openssl x509 -req -SM3 -days 3650 -in server1.csr -extfile ./openssl.cnf -extensions v3enc_req -CA ca.crt -CAkey ca.key -set_serial 1000002001 -out server_en.crt
修改http.conf
增加:LoadModule ssl_module modules/mod_ssl.so
Include conf/ssl.conf
测试通信
命令 # 服务器端运行
/usr/local/gmssl/bin/openssl s_server -accept 4433 -CAfile CA.pem -cert SS.cert.pem -key SS.key.pem -cert SE.cert.pem -key SE.key.pem
# 客户端访问
/usr/local/gmssl/bin/openssl s_client -connect 127.0.0.1:4433 -msg -debug
成功
未解决问题
通过浏览器访问会报错:
浏览器报错:
此网站无法提供安全连接
10.22.2.112 使用了不受支持的协议。 ERR_SSL_VERSION_OR_CIPHER_MISMATCH
协议不受支持
客户端和服务器不支持一般 SSL 协议版本或加密套件
gmssl server端报错: 1. error:1417A0C1:SSL routines:tls_post_process_client_hello:no shared cipher:ssl/statem/statem_srvr.c:1502:
2. 140616840058688:error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure:ssl/record/rec_layer_s3.c:1385:SSL alert number 40
---
no peer certificate available
---
No client certificate CA names sent
2. Apache + Wotrus ssl
大部分流程与 Apache + Gmssl一致,仅需将编译时所需的gmssl替换为wotrus ssl,
wotrus ssl 下载地址:
https://www.wotrus.com/download/wotrus_ssl.tar.gz
通过浏览器可以正常访问,证书显示为国密证书。
问题
若证书使用自己生成的国密证书,会证书验证不通过,提示:
please use wotrus GM signing certificate.
即只能用沃通的证书。
3. Nginx + tls
下载atls
wget https://codeload.github.com/mrpre/atls/zip/master
安装openssl 1.1.1b
wget https://www.openssl.org/source/old/1.1.1/openssl-1.1.1b.tar.gz
安装 openssl-devel
yum install -y openssl-devel
编译安装Nginx1.13.12
wget http://nginx.org/download/nginx-1.13.12.tar.gz
tar -zxf nginx-1.13.12.tar.gz
Nginx中./src/core/ngx_connection.h文件的struct ngx_connection_s中增加: void *a_tls; ./configure --add-module=/$YOURPATH/a_tls/ --with-stream --with-http_ssl_module --with-stream_ssl_module --with-openssl=/$YOURPATH/openssl/
make -j32 && make install
生成签名国密证书和加密国密证书
配置 stream {
....
upstream http_up {
server 127.0.0.1:80;
}
server {
listen 443;
proxy_pass http_up;
a_tls_certificate gm_en.cert;
a_tls_certificate_key gm_en.key;
a_tls_sign_certificate gm_sign.cert;
a_tls_sign_certificate_key gm_sign.key;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers SM2-WITH-SMS4-SM3;
}
}
浏览器成功显示服务端使用了国密证书
错误解决
./libcrypto.so: undefined reference to `EC_KEY_new_from_ECCPUBLICKEYBLOB’
安装依赖yum install libtool perl-core zlib-devel -y
/usr/bin/ld: /usr/local/tassl/lib/libcrypto.a(p12_add.o): relocation R_X86_64_32 against `.rodata.str1.1’ can not be used when making a shared object; recompile with -fPIC
编译时添加shared参数
openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory
export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64
vi /etc/ld.so.conf 添加 /usr/local/lib64 /usr/local/openssl/lib 运行ldconfig
certificate not match
可以尝试签名证书和加密证书使用同一个私钥
相关链接:
Apache mod_ssl.so模块配置参数说明:
https://httpd.apache.org/docs/current/mod/mod_ssl.html
Gmssl:
https://github.com/guanzhi/GmSSL
Tassl:
https://github.com/jntass/TASSL
Tassl/Gmssl简介:
https://www.dazhuanlan.com/2019/10/01/5d92af0087156/
证书管理脚本:
https://blog.stdio.io/1019
国密规范
http://www.gmbz.org.cn/main/bzlb.html
atls
https://github.com/mrpre/atls
通过网页查看服务器算法,服务器使用国密(SM2/SM3/SM4)证书,通过浏览器访问相关推荐
- 服务器使用国密(SM2/SM3/SM4)证书,通过浏览器访问
1. Apache + Gmssl Apache 本身不支持国密,需要修改代码支持GMTLS 下载解压: wget http://archive.apache.org/dist/httpd/httpd ...
- 国密SM2,SM3,SM4的前后台(js和java)加解密写法
目录 SM2加解密 js java SM3加密 js java sm3前后台(js/java)加密不一致原因 SM4加解密 js java 之前做一个项目的时候需要用到国密SM2,SM3,SM4的加解 ...
- OpenSSL 1.1.1 新特性: 全面支持国密SM2/SM3/SM4加密算法
OpenSSL项目最近6个月添加了许多新特性, 包括对中国SM2/SM3/SM4算法的支持: SM2椭圆曲线: https://github.com/openssl/openssl/pull/4793 ...
- 国密 sm2,sm3,sm4 算法纯 JavaScript 实现
2014 年国务院办公厅就颁发了<国务院办公厅转发密码局等部门关于金融领域密码应用指导意见>,指出在我国涉及到金融领域信息安全的产品和系统要自主可控,在金融领域使用国产加密标准是机构走向合 ...
- php gmssl,支持国密SM2/SM3/SM4/SM9/ZUC/SSL的密码工具箱GmSSL
GmSSL概述 GmSSL是一个开源的密码工具箱,支持SM2/SM3/SM4/SM9/ZUC等国密(国家商用密码)算法.SM2国密数字证书及基于SM2证书的SSL/TLS安全通信协议,支持国密硬件密码 ...
- java sm_Java国密SM2/SM3/SM4及证书
1. 使用BC库1.59版本已经可以支持国密算法SM2/SM3/SM4,某大神写的详细测试例子:https://github.com/ZZMarquis/gmhelper 2. 制作证书参考网上资料简 ...
- PB实现国密SM2/SM3/SM4算法(DLL方式)
文章目录 SM4 SM4简介 分组加密模式ECB与CBC ECB模式加密解密 CBC模式加密解密 SM3 SM3简介 SM3摘要生成 SM3WithSM2摘要生成 SM2 SM2简介 SM2签名与验签 ...
- java sm9_一个支持国密SM2/SM3/SM4/SM9/ZUC/SSL的密码工具箱
The GmSSL Project 网址:http://gmssl.org/docs/quickstart.html 在网上闲逛时发现一个工具.SSL支持国密算法.看着比较高大上.还没有用呢.记下来. ...
- 基于mbedTLS算法库实现国密SM2签名和验签算法
网上有大量的基于OpenSSL实现的国密算法库,比如著名的GmSSL,可以直接拿来用.我自己常用的是mbedTLS的算法库,比较小巧简单,在mbedTLS的大数算法的基础上实现了国密SM2的签名和验签 ...
最新文章
- flask简单的登录demo
- Linux shell ==运算符
- NSUserDefaults
- leetcode21
- 科大讯飞2021笔试题
- linux0.11中断描述符,Linux 0.11总结
- 小米Civi 1S获美女产品经理确认:依旧是最美小米机型
- IDEA配置JAVA WEB工程踩坑总结
- C#的TextBox控件输入测试-只允许输入数字的测试:
- unity3D ——自带寻路Navmesh入门教程(一)(转)
- beego mysql增删改查_5-BeegoORM增删改查-Go语言中文社区
- osg加载osgb数据_PCM点云数据处理软件功能使用第十六弹
- 小米随身wifi驱动linux驱动下载,小米随身WIFI驱动|小米WIFI驱动官方最新版(支持Win10)...
- Flutter 本地数据库sqflite实战操作
- 【空气质量数据分析专题四】超标状况分析
- matlab创作歌曲——《月半小夜曲》
- 10【Mybatis延迟加载】
- JOJ 2453 Candy
- 2020-12-20随笔
- 淘宝maven镜像库是个好东西