之前我们项目的证书都是rsa的,这次本意是希望能升级到国密,但是理想过于丰满

一、GMSSL安装

# 下载
wget https://github.com/guanzhi/GmSSL/archive/master.zip
# 解压
unzip master.zip
# 进入目录
cd GmSSL-master
# 配置config指定目录
./config --prefix=/usr/local/gmssl
make
make install
# 查看版本,验证是否安装成功
cd /usr/local/gmssl/
bin/gmssl version
# 报错了,这是由于openssl库的位置不正确造成的
bin/gmssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory
# 现在基本都是建立软连接,但是可能都没说清楚就会比较懵。
# 1.首先确认gmssl的安装路径,我的是/usr/local/gmssl
# 2.应该将gmssl目录下的lib下的对应文件建立软连接
# 3.确认以上两点后,执行下面的命令
ln -s /usr/local/gmssl/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /usr/local/gmssl/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
# 再执行bin/gmssl version,则正常返回版本信息

二、使nginx支持国密

一开始我认认真真的自己编译了nginx和gmssl,换了几个版本,但是编译出来后ssl_protocols都不能使用GMTLS
所谓前人栽树后人乘凉果然有道理,于是我找到了这个
nginx-gm
但是说明比较简约,要不是我自己之前尝试编译了nginx和gmssl,可能现在还在坑里爬不出来

# 下载上面地址的程序并解压
unzip nginx-gm-master.zip
# 进入目录
cd nginx-gm-master/auto/lib/openssl
# 备份原文件
cp conf conf.bak
# 编辑conf,将全部 $OPENSSL/.openssl/修改为$OPENSSL/
vi conf
# 回到原目录
cd nginx-gm-master
# 修改一下 vi build.sh
# 主要修改了nginx安装完后的路径以及gmssl路径
./auto/configure  \--prefix=/usr/local/nginxgm \--with-http_ssl_module \--with-http_realip_module \--with-http_addition_module \--with-http_sub_module \--with-http_dav_module \--with-http_flv_module \--with-http_mp4_module \--with-http_gunzip_module \--with-http_gzip_static_module \--with-http_random_index_module \--with-http_secure_link_module \--with-http_stub_status_module \--with-http_auth_request_module \--with-threads \--with-stream \--with-stream_ssl_module \--with-http_slice_module \--with-mail \--with-mail_ssl_module \--with-file-aio \--with-http_v2_module \--with-openssl=/usr/local/gmssl
# 执行build.sh
sh build.sh
# 安装
make install
# 完成后/usr/local/nginxgm已有相关文件

三、sm2证书生成及验证

1.证书生成

# 1.以下命令在哪个目录执行的就会生成到哪个目录
# 2.openssl.cnf需要放在执行命令的目录下,主要修改了key usage,以便分别生成签名证书和加密证书,这个文件我附在本篇博客最后
# 3.这里-extfile openssl.cnf -extensions v3_ca既是为了区分前面和加密证书也是为了生成v3版本的证书,如果不加生成的是V1版本的
# 4.其实目前这里疑问还是挺多的,但是先上手再说# 生成CA证书/usr/local/gmssl/bin/gmssl ecparam -genkey -name sm2p256v1 -noout -out root.key/usr/local/gmssl/bin/gmssl req -new -key root.key -out root.req -subj "/C=CN/ST=HeBei/L=ShiJiaZhuang/O=WYW/CN=root"/usr/local/gmssl/bin/gmssl x509 -req -days 3650 -sm3 -in root.req -extfile openssl.cnf -extensions v3_ca -signkey root.key -out root.crt# Server签名证书/usr/local/gmssl/bin/gmssl ecparam -name sm2p256v1 -genkey -noout -out server.key/usr/local/gmssl/bin/gmssl req -new -SM3 -key server.key -out server.csr -subj /C=CN/ST=HeBei/L=ShiJiaZhuang/O=WYW/CN="192.168.46.161"/usr/local/gmssl/bin/gmssl x509 -req -SM3 -days 3650 -in server.csr -extfile openssl.cnf -extensions v3_req -CA root.crt -CAkey root.key -set_serial 1000000001 -out server.crt# Server加密证书/usr/local/gmssl/bin/gmssl ecparam -name sm2p256v1 -genkey -noout -out server_en.key/usr/local/gmssl/bin/gmssl req -new -SM3 -key server_en.key -out server1.csr -subj /C=CN/ST=HeBei/L=ShiJiaZhuang/O=WYW/CN="192.168.46.161"/usr/local/gmssl/bin/gmssl x509 -req -SM3 -days 3650 -in server1.csr -extfile openssl.cnf -extensions v3enc_req -CA root.crt -CAkey root.key -set_serial 1000002001 -out server_en.crt# 客户端签名证书/usr/local/gmssl/bin/gmssl ecparam -genkey -name sm2p256v1 -noout -out client.key/usr/local/gmssl/bin/gmssl req -new -key client.key -out client.req -subj "/C=CN/ST=HeBei/L=ShiJiaZhuang/O=WYW/CN=alipay"/usr/local/gmssl/bin/gmssl x509 -req -SM3 -days 3650 -in client.req -extfile openssl.cnf -extensions v3_req -CA root.crt -CAkey root.key -CAcreateserial  -out client.crt# 客户端加密证书/usr/local/gmssl/bin/gmssl ecparam -genkey -name sm2p256v1 -noout -out client_en.key/usr/local/gmssl/bin/gmssl req -new -key client_en.key -out client_en.req -subj "/C=CN/ST=HeBei/L=ShiJiaZhuang/O=WYW/CN=alipay"/usr/local/gmssl/bin/gmssl x509 -req -SM3 -days 3650 -in client_en.req -CA root.crt -extfile openssl.cnf -extensions v3enc_req -CAkey root.key -CAcreateserial  -out client_en.crt

2.验证

2.1 gmssl提供的验证方式

/usr/local/gmssl/bin/gmssl s_server -port 443 -key gmzs2/server.key -cert gmzs2/server.crt  -dkey gmzs2/server_en.key -dcert gmzs2/server_en.crt -CAfile gmzs2/root.crt

2.1.1 s_client验证

我们另外打开一个窗口,用s_client测试一下

/usr/local/gmssl/bin/gmssl s_client -connect localhost:443 -key gmzs2/client.key -cert gmzs2/client.crt -CAfile gmzs2/root.crt


这样也是ok的,在client端输入一些字符,s_server也能收到,哈哈哈哈,发出了莫名的笑声
我试了试就算证书验证失败,s_server还是能收到,微笑.jpg
就是这个client让我迷茫的一点是,为什么要带上根证书呢?

2.1.2 浏览器验证

这里我先用的密信浏览器,是能访问到的,360不行,可能需要后续研究

2.1 nginx验证

nginx-gm
回到我们刚才安装好的nginx,修改配置文件,这个说明里说需要配置三套证书(国密签名证书、国密加密证书、其他普通证书)
-0-在我积极的测试中发现其他普通证书指的是根证书,配置其他的都报错了。如下

# vi nginx.conf
server {listen       443 ssl;server_name  localhost;ssl_certificate      /usr/local/gmzs2/server.crt;ssl_certificate_key  /usr/local/gmzs2/server.key;ssl_certificate      /usr/local/gmzs2/server_en.crt;ssl_certificate_key  /usr/local/gmzs2/server_en.key;ssl_protocols TLSv1.2 TLSv1.3 GMTLS;ssl_certificate      /usr/local/gmzs2/root.crt;ssl_certificate_key  /usr/local/gmzs2/root.key;ssl_session_cache    shared:SSL:1m;ssl_session_timeout  5m;ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:ECDHE-SM2-WITH-SMS4-GCM-SM3:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-SM2-WITH-SMS4-SHA256:ECDHE-SM2-WITH-SMS4-SM3:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA:RSA-PSK-AES256-GCM-SHA384:DHE-PSK-AES256-GCM-SHA384:RSA-PSK-CHACHA20-POLY1305:DHE-PSK-CHACHA20-POLY1305:ECDHE-PSK-CHACHA20-POLY1305:AES256-GCM-SHA384:PSK-AES256-GCM-SHA384:PSK-CHACHA20-POLY1305:RSA-PSK-AES128-GCM-SHA256:DHE-PSK-AES128-GCM-SHA256:AES128-GCM-SHA256:PSK-AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:ECDHE-PSK-AES256-CBC-SHA384:ECDHE-PSK-AES256-CBC-SHA:SRP-RSA-AES-256-CBC-SHA:SRP-AES-256-CBC-SHA:RSA-PSK-AES256-CBC-SHA384:DHE-PSK-AES256-CBC-SHA384:RSA-PSK-AES256-CBC-SHA:DHE-PSK-AES256-CBC-SHA:AES256-SHA:PSK-AES256-CBC-SHA384:PSK-AES256-CBC-SHA:ECDHE-PSK-AES128-CBC-SHA256:ECDHE-PSK-AES128-CBC-SHA:SRP-RSA-AES-128-CBC-SHA:SRP-AES-128-CBC-SHA:RSA-PSK-AES128-CBC-SHA256:DHE-PSK-AES128-CBC-SHA256:RSA-PSK-AES128-CBC-SHA:DHE-PSK-AES128-CBC-SHA:SM9-WITH-SMS4-SM3:SM9DHE-WITH-SMS4-SM3:SM2-WITH-SMS4-SM3:SM2DHE-WITH-SMS4-SM3:AES128-SHA:RSA-WITH-SMS4-SHA1:RSA-WITH-SMS4-SM3:PSK-AES128-CBC-SHA256:PSK-AES128-CBC-SHA;# ssl_ciphers  HIGH:!aNULL:!MD5;ssl_prefer_server_ciphers  on;location / {root   html;index  index.html index.htm;}}
# 检查配置文件
sbin/nginx -t
# 无误后启动
sbin/nginx

我们打开密信浏览器进行验证,ok的,可以访问

四、用java生成客户端证书

其实这里我真的借鉴了很多代码,以下列上对我影响最大的两份开源代码,以表敬意。这两份开源代码让我对SM2数字证书从懵逼到稍微有那么一点了解,我最后写成的代码主要是生成客户端证书,所以都是从这里面借鉴的,供大家参考。
gmhelper
littleca
如果有需求简单也只需要生成客户端证书的也可以联系我。
吊销延期等操作只有RSA版本的,这个以后也可以写篇博客,现在网上流传的版本大多都过时了。

五、通信期望

1.其实这个我一开始还挺懵的,研究了一下发现好像现在没有对GMTLS的通信支持,比如携带sm2证书请求https接口这类的,其实这个初衷就是为了这个接口通信,尝试了但是都握手失败了,这个需要后续研究

2.但是还是记录一下我能解析携带sm2证书的步骤

//指定读取证书格式为PKCS12
KeyStore keyStore = KeyStore.getInstance("PKCS12");

一开始我指定读取证书格式为PKCS12,报了Unknown named curve: 1.2.156.10197.1.301这个错

Exception in thread "main" java.security.cert.CertificateParsingException: java.io.IOException: Unknown named curve: 1.2.156.10197.1.301

后来修改为这样

KeyStore keyStore = KeyStore.getInstance("PKCS12", "BC");

又报错

java.security.NoSuchProviderException: no such provider: BC

解决方法是修改该程序所用的jdk的jre/lib/security目录下的java.security,增加如下配置,这个数字是几可以按你文件里最后一个+1即可

security.provider.11=org.bouncycastle.jce.provider.BouncyCastleProvider

这样就能解析证书了,完整代码如下,大家调试的时候也可以配置上-Djavax.net.debug=all

package com.wyw.exchange.controller;import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.security.KeyStore;
import java.security.Security;import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.InputStreamEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContexts;public class TestController {public static String sendRedEnvelope(String url, String param) throws Exception {//PKCS12的密码String PKCS12 = "123456";//证书地址String fileRoute = "F:\\cert\\client\\sm2\\client/1599630757129/client.p12";//指定读取证书格式为PKCS12//KeyStore keyStore = KeyStore.getInstance("PKCS12");KeyStore keyStore = KeyStore.getInstance("PKCS12", "BC");//读取本机存放的PKCS12证书文件FileInputStream instream = new FileInputStream(new File(fileRoute));try (InputStream is = Files.newInputStream(Paths.get(fileRoute),StandardOpenOption.READ)) {keyStore.load(is, PKCS12.toCharArray());}//指定TLS版本SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, PKCS12.toCharArray()).build();//设置httpclient的SSLSocketFactorySSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext,new String[]{"TLSv1.2"},null,SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);CloseableHttpClient httpclient = HttpClients.custom().setSSLSocketFactory(sslsf).build();StringBuffer stringBuffer = new StringBuffer();try {HttpPost httpPost = new HttpPost(url);InputStream is = new ByteArrayInputStream(param.getBytes("UTF-8"));//InputStreamEntity严格是对内容和长度相匹配的。用法和BasicHttpEntity类似InputStreamEntity inputStreamEntity = new InputStreamEntity(is, is.available());httpPost.setEntity(inputStreamEntity);CloseableHttpResponse response = httpclient.execute(httpPost);try {HttpEntity entity = response.getEntity();BufferedReader reader = new BufferedReader(new InputStreamReader(entity.getContent(), "UTF-8"));String inputLine;while ((inputLine = reader.readLine()) != null) {stringBuffer.append(inputLine);}} finally {response.close();}} finally {httpclient.close();}return stringBuffer.toString();}public static void main(String args[]) throws Exception {sendRedEnvelope("https://192.168.46.161:443","123");}
}

如上我的国密数字证书探索之旅也结束了,如果以上有任何问题的话请与我联系,多多指教!

--------------------分割线,到这里就结束了,下面附openssl-------------------------

key usage扩展为Digital Signature, Non-Repudiation, Key Encipherment(e0),证书可以用来加密和签名。
key usage扩展为Digital Signature没有加密功能,只能用来签名。
key usage扩展为keyEncipherment没有签名功能,只能用来加密。

openssl.cnf

#
# OpenSSL example configuration file.
# This is mostly being used for generation of certificate requests.
## This definition stops the following lines choking if HOME isn't
# defined.
HOME            = .
RANDFILE        = $ENV::HOME/.rnd# Extra OBJECT IDENTIFIER info:
#oid_file       = $ENV::HOME/.oid
oid_section     = new_oids# To use this configuration file with the "-extfile" option of the
# "openssl x509" utility, name here the section containing the
# X.509v3 extensions to use:
# extensions        =
# (Alternatively, use a configuration file that has only
# X.509v3 extensions in its main [= default] section.)[ new_oids ]# We can add new OIDs in here for use by 'ca', 'req' and 'ts'.
# Add a simple OID like this:
# testoid1=1.2.3.4
# Or use config file substitution like this:
# testoid2=${testoid1}.5.6# Policies used by the TSA examples.
tsa_policy1 = 1.2.3.4.1
tsa_policy2 = 1.2.3.4.5.6
tsa_policy3 = 1.2.3.4.5.7####################################################################
[ ca ]
default_ca  = CA_default       # The default ca section####################################################################
[ CA_default ]dir       = /usr/local/gmzs2     # Where everything is kept
certs       = $dir/certs       # Where the issued certs are kept
crl_dir     = $dir/crl     # Where the issued crl are kept
database    = $dir/index.txt   # database index file.
#unique_subject = no           # Set to 'no' to allow creation of# several certs with same subject.
new_certs_dir   = $dir/newcerts        # default place for new certs.certificate   = $dir/cacert.pem  # The CA certificate
serial      = $dir/serial      # The current serial number
crlnumber   = $dir/crlnumber   # the current crl number# must be commented out to leave a V1 CRL
crl     = $dir/crl.pem         # The current CRL
private_key = $dir/private/cakey.pem # The private key
RANDFILE    = $dir/private/.rand   # private random number filex509_extensions = usr_cert     # The extensions to add to the cert# Comment out the following two lines for the "traditional"
# (and highly broken) format.
name_opt    = ca_default       # Subject Name options
cert_opt    = ca_default       # Certificate field options# Extension copying option: use with caution.
# copy_extensions = copy# Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs
# so this is commented out by default to leave a V1 CRL.
# crlnumber must also be commented out to leave a V1 CRL.
# crl_extensions    = crl_extdefault_days  = 365          # how long to certify for
default_crl_days= 30           # how long before next CRL
default_md  = default      # use public key default MD
preserve    = no           # keep passed DN ordering# A few difference way of specifying how similar the request should look
# For type CA, the listed attributes must be the same, and the optional
# and supplied fields are just that :-)
policy      = policy_match# For the CA policy
[ policy_match ]
countryName     = match
stateOrProvinceName = match
organizationName    = match
organizationalUnitName  = optional
commonName      = supplied
emailAddress        = optional# For the 'anything' policy
# At this point in time, you must list all acceptable 'object'
# types.
[ policy_anything ]
countryName     = optional
stateOrProvinceName = optional
localityName        = optional
organizationName    = optional
organizationalUnitName  = optional
commonName      = supplied
emailAddress        = optional####################################################################
[ req ]
default_bits        = 2048
default_keyfile     = privkey.pem
distinguished_name  = req_distinguished_name
attributes      = req_attributes
x509_extensions = v3_ca    # The extensions to add to the self signed cert# Passwords for private keys if not present they will be prompted for
# input_password = secret
# output_password = secret# This sets a mask for permitted string types. There are several options.
# default: PrintableString, T61String, BMPString.
# pkix   : PrintableString, BMPString (PKIX recommendation before 2004)
# utf8only: only UTF8Strings (PKIX recommendation after 2004).
# nombstr : PrintableString, T61String (no BMPStrings or UTF8Strings).
# MASK:XXXX a literal mask value.
# WARNING: ancient versions of Netscape crash on BMPStrings or UTF8Strings.
string_mask = utf8only# req_extensions = v3_req # The extensions to add to a certificate request[ req_distinguished_name ]
countryName         = Country Name (2 letter code)
countryName_default     = CN
countryName_min         = 2
countryName_max         = 2stateOrProvinceName     = State or Province Name (full name)
stateOrProvinceName_default = Some-StatelocalityName           = Locality Name (eg, city)0.organizationName       = Organization Name (eg, company)
0.organizationName_default  = Internet Widgits Pty Ltd# we can do this but it is not needed normally :-)
#1.organizationName     = Second Organization Name (eg, company)
#1.organizationName_default = World Wide Web Pty LtdorganizationalUnitName     = Organizational Unit Name (eg, section)
#organizationalUnitName_default =commonName            = Common Name (e.g. server FQDN or YOUR name)
commonName_max          = 64emailAddress           = Email Address
emailAddress_max        = 64# SET-ex3          = SET extension number 3[ req_attributes ]
challengePassword       = A challenge password
challengePassword_min       = 4
challengePassword_max       = 20unstructuredName       = An optional company name[ usr_cert ]# These extensions are added when 'ca' signs a request.# This goes against PKIX guidelines but some CAs do it and some software
# requires this to avoid interpreting an end user certificate as a CA.basicConstraints=CA:FALSE# Here are some examples of the usage of nsCertType. If it is omitted
# the certificate can be used for anything *except* object signing.# This is OK for an SSL server.
# nsCertType            = server# For an object signing certificate this would be used.
# nsCertType = objsign# For normal client use this is typical
# nsCertType = client, email# and for everything including object signing:
# nsCertType = client, email, objsign# This is typical in keyUsage for a client certificate.
# keyUsage = nonRepudiation, digitalSignature, keyEncipherment
# keyUsage = digitalSignature
keyUsage = keyEncipherment# This will be displayed in Netscape's comment listbox.
nsComment           = "OpenSSL Generated Certificate"# PKIX recommendations harmless if included in all certificates.
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer# This stuff is for subjectAltName and issuerAltname.
# Import the email address.
# subjectAltName=email:copy
# An alternative to produce certificates that aren't
# deprecated according to PKIX.
# subjectAltName=email:move# Copy subject details
# issuerAltName=issuer:copy#nsCaRevocationUrl      = http://www.domain.dom/ca-crl.pem
#nsBaseUrl
#nsRevocationUrl
#nsRenewalUrl
#nsCaPolicyUrl
#nsSslServerName# This is required for TSA certificates.
# extendedKeyUsage = critical,timeStamping[ v3_req ]# Extensions to add to a certificate requestbasicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature[ v3enc_req ]# Extensions to add to a certificate requestbasicConstraints = CA:FALSE
keyUsage = keyAgreement, keyEncipherment, dataEncipherment[ v3_ca ]# Extensions for a typical CA# PKIX recommendation.subjectKeyIdentifier=hashauthorityKeyIdentifier=keyid:always,issuerbasicConstraints = critical,CA:true# Key usage: this is typical for a CA certificate. However since it will
# prevent it being used as an test self-signed certificate it is best
# left out by default.
keyUsage = cRLSign, keyCertSign# Some might want this also
# nsCertType = sslCA, emailCA# Include email address in subject alt name: another PKIX recommendation
# subjectAltName=email:copy
# Copy issuer details
# issuerAltName=issuer:copy# DER hex encoding of an extension: beware experts only!
# obj=DER:02:03
# Where 'obj' is a standard or added object
# You can even override a supported extension:
# basicConstraints= critical, DER:30:03:01:01:FF[ crl_ext ]# CRL extensions.
# Only issuerAltName and authorityKeyIdentifier make any sense in a CRL.# issuerAltName=issuer:copy
authorityKeyIdentifier=keyid:always[ proxy_cert_ext ]
# These extensions should be added when creating a proxy certificate# This goes against PKIX guidelines but some CAs do it and some software
# requires this to avoid interpreting an end user certificate as a CA.basicConstraints=CA:FALSE# Here are some examples of the usage of nsCertType. If it is omitted
# the certificate can be used for anything *except* object signing.# This is OK for an SSL server.
# nsCertType            = server# For an object signing certificate this would be used.
# nsCertType = objsign# For normal client use this is typical
# nsCertType = client, email# and for everything including object signing:
# nsCertType = client, email, objsign# This is typical in keyUsage for a client certificate.
# keyUsage = nonRepudiation, digitalSignature, keyEncipherment# This will be displayed in Netscape's comment listbox.
nsComment           = "OpenSSL Generated Certificate"# PKIX recommendations harmless if included in all certificates.
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer# This stuff is for subjectAltName and issuerAltname.
# Import the email address.
# subjectAltName=email:copy
# An alternative to produce certificates that aren't
# deprecated according to PKIX.
# subjectAltName=email:move# Copy subject details
# issuerAltName=issuer:copy#nsCaRevocationUrl      = http://www.domain.dom/ca-crl.pem
#nsBaseUrl
#nsRevocationUrl
#nsRenewalUrl
#nsCaPolicyUrl
#nsSslServerName# This really needs to be in place for it to be a proxy certificate.
proxyCertInfo=critical,language:id-ppl-anyLanguage,pathlen:3,policy:foo####################################################################
[ tsa ]default_tsa = tsa_config1   # the default TSA section[ tsa_config1 ]# These are used by the TSA reply generation only.
dir     = ./demoCA     # TSA root directory
serial      = $dir/tsaserial   # The current serial number (mandatory)
crypto_device   = builtin      # OpenSSL engine to use for signing
signer_cert = $dir/tsacert.pem     # The TSA signing certificate# (optional)
certs       = $dir/cacert.pem  # Certificate chain to include in reply# (optional)
signer_key  = $dir/private/tsakey.pem # The TSA private key (optional)
signer_digest   = sm3          # Signing digest to use. (Optional)
default_policy  = tsa_policy1      # Policy if request did not specify it# (optional)
other_policies  = tsa_policy2, tsa_policy3     # acceptable policies (optional)
digests     = sm3, sha256, sha384, sha512      # Acceptable message digests (mandatory)
accuracy    = secs:1, millisecs:500, microsecs:100 # (optional)
clock_precision_digits  = 0    # number of digits after dot. (optional)
ordering        = yes  # Is ordering defined for timestamps?# (optional, default: no)
tsa_name        = yes  # Must the TSA name be included in the reply?# (optional, default: no)
ess_cert_id_chain   = no   # Must the ESS cert id chain be included?# (optional, default: no)

【国密】利用gmssl生成SM2证书nginx访问相关推荐

  1. Windows gmssl生成SM2证书 + java bc库签名验签

    Windows gmssl生成SM2证书 + java bc库签名验签 openssl生成SM2证书 1 生成密钥 gmssl ecparam -genkey -name sm2p256v1 -tex ...

  2. gmssl 生成SM2证书、加密、解密、签名、验签

    1. 生成SM2密钥对 gmssl ecparam -genkey -name sm2p256v1   -out sm2keypair.pem -text 2.查看SM2密钥对 gmssl ec -i ...

  3. 国密gmssl命令行生成SM2证书

    简介 这周,实习公司要我去了解一下gmssl生成证书的流程,以便之后去验证SKF的证书接口.首先就来体验一下用指令完整证书的生成操作.目前,有一些文章已经有相关的详细介绍,但还是存在一定问题,如:CA ...

  4. 国密SSL协议之双证书体系

    1 背景 国密SSL协议使用双证书体系.本文描述了国密双证书体系的组成和差别,并描述了在U盾里面的使用情况. 2 国密SSL双证书 国密SSL协议使用双证书体系,分别称为签名证书和加密证书,服务器和用 ...

  5. 关于国密算法 SM1,SM2,SM3,SM4 的笔记

    关于国密算法 SM1,SM2,SM3,SM4 的笔记 国密即国家密码局认定的国产密码算法.主要有SM1,SM2,SM3,SM4.密钥长度和分组长度均为128位. SM1 为对称加密.其加密强度与AES ...

  6. 浅谈国密算法 SM1、SM2、SM3、SM4

    浅谈国密算法 国密算法是我国自主研发创新的一套数据加密处理系列算法.从SM1-SM4分别实现了对称.非对称.摘要等算法功能.特别适合应用于嵌入式物联网等相关领域,完成身份认证和数据加解密等功能.当然, ...

  7. 密信国密浏览器,为SM2商密算法普及提供生态支持

    为什么80%的码农都做不了架构师?>>>    日前,密信浏览器(MeSince Browser)公测版问世,完整支持SM2商密算法和商密SSL证书,为SM2商密算法在HTTPS加密 ...

  8. 国密SM4加解密SM2签名验签COM组件DLL

    提供给第三方软件,调用COM组件DLL方式进行实现,如delphi.PB等. 基于C#编写的COM组件DLL,可实现SM2签名验签,SM4加解密,100%适用于黑龙江省国家医保接口中进行应用. 功能包 ...

  9. 利用openssl生成X509证书

    利用openssl生成X509证书 1.生成密钥 openssl genrsa -out test.key 2048 2.生成cert证书(sha512/sha256/sha1要根据实际算法) ope ...

最新文章

  1. pytorch argsort
  2. hibernate -- HQL语句总结
  3. Android开发常用开源框架:图片处理
  4. 安卓手机如何打开php文件夹,Android_Android中调用系统的文件浏览器及自制简单的文件浏览器,调用系统自带的文件浏览器- phpStudy...
  5. performance 查看页面性能
  6. Win11手机应用大改!全新界面来袭
  7. 用户首次登录之前必须更改密码_技术丨带你玩转Win10系统的用户账户
  8. 分享实录 | 企业CICD规模化落地浅析
  9. 第25课 成绩等级 《小学生C++趣味编程》
  10. 人工智障学习笔记——机器学习(12)LDA降维
  11. mysql ddl 失败_PHP加载mysql DDL会失败
  12. 有一动态生成的TABLE,当点击该TABLE中的按钮时,如何得到该按钮所在行的某一列的值啊?...
  13. slf4j+log4j在Java中实现日志记录
  14. window xp系统安装php环境_在Windows XP下安装Apache+MySQL+PHP环境
  15. C语言中pow()指数函数的使用问题简述
  16. [CTF]利用CRC32绕过RAR密码(适合于小文本文件)
  17. cmd导入数据到Oracle,oracle在cmd下通过命令导入导出数据
  18. win10取消登录密码
  19. QNAP威联通NAS搭建SFTP服务,并内网穿透实现公网远程访问
  20. 高数巨占座问题(c语言)

热门文章

  1. 大江狗的新博客长啥样?
  2. 数据解读广大“钢铁直男”眼中的女神评判标准
  3. 【踩坑】requests 使用 IP 代理时 ValueError: check_hostname requires server_hostname
  4. python编程之 环绕卫星轨道
  5. php正则匹配包含某个字符串,php正则如何不包含某字符串
  6. 2.授之以渔--自由
  7. 关于D3D的学习和个人理解-1
  8. c 中空格的asc码表_[转]回车、换行、空格的ASCII码值—(附ASCII码表)
  9. cr2032和br2032区别_cr1632和cr2032的区别?可互换?
  10. OpenJDK 初步探索