OpenSSL个人心得

OpenSSL

安装


Windows

地址:http://slproweb.com/products/Win32OpenSSL.html

配置环境变量


配置两个环境变量,一个是OPENSSL_HOME,另一个要配置到Path

OPENSSL_HOME:就是 OpenSSL 的安装目录

Path:就是OPENSSL_HOME目录下的bin目录

命令


ecparam

椭圆曲线密钥参数生成及操作。

椭圆曲线(ECC)算法是一种公钥算法,它比流行的RSA算法有很多优点:

  • 安全性能更高 , 如160位ECC与1024位RSA、DSA有相同的安全强度。
  • 计算量小,处理速度快, 在私钥的处理速度上(解密和签名),ECC比RSA、DSA快得多。
  • 存储空间占用小 ECC的密钥尺寸和系统参数与RSA、DSA相比要小得多, 所以占用的存储空间小得多。
  • 带宽要求低。

用法:

openssl ecparam [-inform DER|PEM] [-outform DER|PEM] [-in filename] [-out filename] [-noout] [-text] [-C] [-check] [-name arg] [-list_curve] [-conv_form arg] [-param_enc arg] [-no_seed] [-rand file(s)] [-genkey] [-engine id]

解释:

-list_curves:打印所有可用的算法曲线

-genkey:生成密钥

-name:使用指定的算法曲线

-out:输出文件

例子:

比特币选取了 secp256k1 作为算法曲线

# 使用 secp256k1 作为算法曲线,生成 EC 参数和私钥,并输出到 ca-key_.key 文件中
openssl ecparam -genkey -name secp256k1 -out ca-key_.key

pkcs8

pkcs8格式的私钥转换工具

用法:

openssl pkcs8 [-inform PEM|DER] [-outform PEM|DER] [-in filename] [-passin arg] [-out filename] [-passout arg] [-topk8] [-noiter] [-nocrypt] [-nooct] [-embed] [-nsdb] [-v2 alg] [-v1 alg] [-engine id]

解释:

-topk8:输出pkcs8文件

-v2:采用PKCS#5 v2.0,并指定加密算法

-inform:输入文件格式

-outform:输出文件格式

-in:输入文件

-out:指定输出文件

例子:

CBC模式:Cipher-block chaining,密码块连接模式。

目前,CBC是最为常用的工作模式。

  • 每一次加密都需要前一个密文块参与,明文中微小的改变都会使后续所有密文改变;
  • 无法从密文看出明文的规律。安全性得以提高。

CTR模式:Counter mode,计数器模式。

CTR 模式被广泛用于 ATM 网络安全和 IPSec应用中,相对于其它模式而言,CRT模式具有如下特点:

  • 硬件效率:允许同时处理多块明文 / 密文。
  • 软件效率:允许并行计算,可以很好地利用 CPU 流水等并行技术。
  • 预处理:算法和加密盒的输出不依靠明文和密文的输入,因此如果有足够的保证安全的存储器,加密算法将仅仅是一系列异或运算,这将极大地提高吞吐量。
  • 随机访问:第 i 块密文的解密不依赖于第 i-1 块密文,提供很高的随机访问能力。
  • 可证明的安全性:能够证明 CTR 至少和其他模式一样安全(CBC, CFB, OFB, …)
  • 简单性:与其它模式不同,CTR模式仅要求实现加密算法,但不要求实现解密算法。对于 AES 等加/解密本质上不同的算法来说,这种简化是巨大的。
  • 无填充,可以高效地作为流式加密使用。
# 使用 aes-256-cbc 加密算法,将存有 EC 参数和私钥的 ca-key_.key 文件,转换为带有密码保护的 PEM 格式的 pkcs8 文件
openssl pkcs8 -topk8 -v2 aes-256-cbc -inform PEM -outform PEM -in ca-key_.key -out ca-key.key
# 到了这一步,其实可以把没有密码保护的 ca-key_.pem 删除

req

req命令主要用于生成和处理PKCS#10证书请求。

用法:

openssl req [-inform PEM|DER] [-outform PEM|DER] [-in filename] [-passin arg] [-out filename] [-passout arg] [-text] [-pubkey] [-noout] [-verify] [-modulus] [-new] [-rand file(s)] [-newkey rsa:bits] [-newkey dsa:file] [-nodes] [-key filename] [-keyform PEM|DER] [-keyout filename] [-[md5|sha1|md2|mdc2]] [-config filename] [-subj arg] [-multivalue-rdn] [-x509] [-days n] [-set_serial n] [-asn1-kludge] [-newhdr] [-extensions section] [-reqexts section] [-utf8] [-nameopt] [-batch] [-verbose] [-engine id]

解释:

-new:生成新的证书请求以及私钥,默认为1024比特。

-utf8:输入字符为utf8编码,默认输入为ASCII编码。

-config:指定证书请求模板文件,默认采用openssl.cnf,需另行指定时用此选项。配置的写法可以参考openssl.cnf,其中有关于生成证书请求的设置。

-key:证书私钥文件的来源。允许该文件的格式是PKCS#8

-subj:用于指定生成的证书请求的用户信息,或者处理证书请求时用指定参数替换。生成证书请求时,如果不指定此选项,程序会提示用户来输入各个用户信息,包括国名、组织等信息,如果采用此选择,则不需要用户输入了。比如:-subj /CN=china/OU=test/O=abc/CN=forxy,注意这里等属性必须大写。

-out:要输出的文件名

例子:

证书请求的用户信息:-subj "/C=国家代码简称/ST=州或省份名称/L=城市或区域名称/OU=组织单位名称/O=组织名称/CN=通用名称(可以是带有通配符的域名)"

# 使用 openssl.cnf 作为证书请求模板文件,生成 ca-req.csr 证书请求文件,指定编码为 utf8 ,并指定用户信息(下面以 baidu.com 的证书信息为例)
openssl req -new -utf8 -config openssl.cnf -key ca-key.key -subj "/C=CN/ST=Guangdong/L=Guangzhou/OU=service operation department/O=Beijing Baidu Netcom Science Technology Co., Ltd./CN=*.baidu.com" -out ca-req.csr

x509(CA颁发证书给自己)

X509命令是一个多用途的证书工具。它可以显示证书信息、转换证书格式、签名证书请求以及改变证书的信任设置等。

用法:

openssl x509 [-inform DER|PEM|NET] [-outform DER|PEM|NET] [-keyform DER|PEM] [-CAform DER|PEM] [-CAkeyform DER|PEM] [-in filename] [-out filename] [-serial] [-hash] [-subject_hash] [-issuer_hash] [-subject] [-issuer] [-nameopt option] [-email] [-startdate] [-enddate] [-purpose] [-dates] [-modulus] [-fingerprint] [-alias] [-noout] [-trustout] [-clrtrust] [-clrreject] [-addtrust arg] [-addreject arg] [-setalias arg] [-days arg] [-set_serial n] [-signkey filename] [-x509toreq] [-req] [-CA filename] [-CAkey filename] [-CAcreateserial] [-CAserial filename] [-text] [-C] [-md2|-md5|-sha1|-mdc2] [-clrext] [-extfile filename] [-extensions section] [-engine id]

解释:

-req:输入为证书请求,需要进行处理。

-extfile:指定包含证书扩展项的文件名,如果没有,那么生成的证书将没有任何扩展项。

-extensions:使用X509V3扩展的配置文件的部分。

-days:设置证书有效期,arg为天数。

-CAcreateserial:如果序证书列号文件,则生成。

-signkey:指定自签名私钥文件。

-in:指定输入文件名。

-out:指定输出文件名。

例子:

# CA 自颁证书,使用包含证书扩展项的 openssl.cnf 文件中 v3_ca 的部分,有效期为 2 年,使用自签名私钥文件 ca-key.key 进行签发
openssl x509 -req -extfile openssl.cnf -extensions v3_ca -days 730 -CAcreateserial -signkey ca-key.key -in ca-req.csr -out ca-cert.crt

ca(CA颁发证书给其他人)

ca命令是一个小型CA系统。它能签发证书请求和生成CRL。它维护一个已签发证书状态的文本数据库。

用法:

openssl ca [-verbose] [-config filename] [-name section] [-gencrl] [-revoke file] [-crl_reason reason] [-crl_hold instruction] [-crl_com promise time] [-crl_CA_compromise time] [-subj arg] [-crldays days] [-crlhours hours] [-crlexts section] [-startdate date] [-enddate date] [-days arg] [-md arg] [-policy arg] [-keyfile arg] [-key arg] [-passin arg] [-cert file] [-in file] [-out file] [-notext] [-outdir dir] [-infiles] [-spkac file] [-ss_cert file] [-preserveDN] [-noemailDN] [-batch] [-msie_hack] [-extensions section] [-extfile section] [-engine id] [-utf8] [-multivalue-rdn]

解释:

-utf8:表明任何输入都必须是utf8编码(用户的终端输入和配置文件),默认为ASCII编码。

-config:指定配置文件,此配置文件中包含了证书存放路径、私钥和生成证书控制等信息。如果默认安装openssl,配置文件在 /usr/local/ssl/ 路径下。我们可以先用apps目录下的CA.sh或者CA.pl脚本来 建立环境:sh CA.sh -newca ,输入后回车就会生成一个demonCA的目录。

-extensions:如果没有通过-extfile选项指定扩展项信息,section为配置文件中与扩展项有关的段,签发证书时添加section指定的扩展项(默认采用x509_extensions),如果不指定扩展,将生成第一版本的数字证书。

-days:设置证书有效期,arg为天数。

-create_serial

-keyfile:指定签发证书的私钥文件。

-cert:指定CA证书文件。

-in:输入的证书请求文件。

-out:输出文件名。

例子:

# CA 颁发证书,编码为 utf8 ,使用包含证书扩展项的 openssl.cnf 文件中 v3_req 的部分,有限期为 2 年,根 CA 是 ca-cert.crt 证书文件,使用根 CA 的私钥进行签名
openssl ca -utf8 -config openssl.cnf -extensions v3_req -days 730 -create_serial -keyfile ca-key.key -cert ca-cert.crt -in server-req.csr -out server-cert.crt

pkcs12(证书格式转换)

用法:

openssl pkcs12 [-export] [-chain] [-inkey filename] [-certfile filename] [-CApath arg] [-CAfile arg] [-name name] [-caname name] [-in filename] [-out filename] [-noout] [-nomacver] [-nocerts] [-clcerts] [-cacerts] [-nokeys] [-info] [-des] [-des3] [-aes128] [-aes192] [-aes256] [-idea] [-nodes] [-noiter] [-maciter] [-twopass] [-descert] [-certpbe alg] [-keypbe alg] [-keyex] [-keysig] [-password arg] [-passin arg] [-passout arg] [-rand file(s)] [-engine e]

解释:

-export:输出pkcs12文件。

-clcerts:只输出客户证书,不包含CA证书。

-inkey:指定私钥文件,如果不用此选项,私钥必须在-in filename中指定。

-nokeys:不输出私钥。

-in:指定私钥和证书读取的文件,必须为PEM格式。

-out:指定输出的pkcs12文件,默认为标准输出。

例子:

# CRT 转 PFX
openssl pkcs12 -export -inkey ca-key.key -in ca-cert.crt -out ca-cert.pfx
# PFX 转 CRT
openssl pkcs12 -clcerts -nokeys -in ca-cert.pfx -out ca-cert.crt

OpenSSL配置文件


详细信息

打开证书你能发现详细信息里有很多个字段,每隔字段对应一个值

公钥、公钥参数

openssl ecparam 命令的 -name 参数有关

增强型密钥用法

extendedKeyUsage对应
serverAuth服务器身份验证
clientAuth客户端身份验证
emailProtection安全电子邮件
timeStamping时间戳
codeSigning代码签名
msEFS加密文件系统
ipsecTunnelIP 安全隧道终止
ipsecUserIP 安全用户
OCSPSigningOCSP 签名

对应的代码(好像大部分证书都按这个顺序来排,我不知道这其中有什么讲究,所以就随大流了):

extendedKeyUsage = clientAuth, codeSigning, msEFS, emailProtection, ipsecTunnel, ipsecUser, OCSPSigning, serverAuth, timeStamping

密钥用法

keyUsage对应
digitalSignatureDigital Signature
nonRepudiationNon-Repudiation
keyEnciphermentKey Encipherment
dataEnciphermentData Encipherment
keyAgreementKey Agreement
keyCertSignCertificate Signing
cRLSignOff-line CRL Signing、CRL Signing
encipherOnlyEncipher Only
decipherOnlyDecipher Only

对应的代码(根据自己所需的,或者仿照其他的 Root CA 证书;不需要全部填):

keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment, keyAgreement, keyCertSign, cRLSign, encipherOnly, decipherOnly

基本约束

basicConstraints对应
CA:trueSubject Type=CA
CA:FALSESubject Type=End Entity
pathlen:0Path Length Constraint=0
# CA
basicConstraints = CA:true
# 中间 CA
basicConstraints = CA:true, pathlen:0
# 非 CA
basicConstraints = CA:FALSE

使用者可选名称

对应的代码:

subjectAltName = @server_alt_names...[ server_alt_names ]
DNS.1 = *.localhost
DNS.2 = *.test.com
IP.1 = 192.168.9.101

颁发者备用名称

对应的代码:

issuerAltName = @ca_alt_names...[ ca_alt_names ]
DNS.1 = Test Root CA
DNS.2 = *.test.com
IP.1 = 192.168.200.11

Netscape Cert Type

nsCertType对应
clientSSL 客户端身份验证
serverSSL 服务器身份验证
emailSMIME
objsign签名
sslCASSL CA
emailCASMIME CA
objCA签名 CA

对应的代码(根据自己所需的,或者仿照其他的 Root CA 证书;不需要全部填):

nsCertType = client, server, email, objsign, sslCA, emailCA, objCA

Netscape Comment

对应的代码:

nsComment = "你想显示的内容"

模板

#
# OpenSSL配置文件示例。
# 这主要用于生成证书请求。
## 注意,你可以使用.include指令从主配置文件中包含其他文件。
#.include filename# 如果没有定义HOME,此定义将停止下面的行阻塞。
HOME			= .# 额外的对象标识符信息:
#oid_file		= $ENV::HOME/.oid
oid_section		= new_oids# 要在“openssl x509”实用程序的“-extfile”选项中使用此配置文件,请在这里指定包含要使用的X.509v3扩展名的部分:
# extensions		=
# (或者,使用一个在main [= default]部分中只有X.509v3扩展名的配置文件。)[ new_oids ]# 我们可以在这里添加新的oid以供'ca', 'req'和'ts'使用。
# 像这样添加一个简单的OID:
# testoid1=1.2.3.4
# 或者像这样使用配置文件替换:
# testoid2=${testoid1}.5.6# TSA示例使用的策略。
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		# 默认ca章节####################################################################
[ CA_default ]dir		= ./demoCA		# 所有东西都放在那里
certs		= $dir/certs		# 已发出的证书存放于何处
crl_dir		= $dir/crl		# 已签发的crl保存在何处
database	= $dir/index.txt	# 数据库索引文件
#unique_subject	= no			# 设置为“no”以允许创建多个具有相同主题的证书。
new_certs_dir	= $dir/newcerts		# 新证书的默认位置。certificate	= $dir/cacert.pem 	# CA证书
serial		= $dir/serial 		# 当前序列号
crlnumber	= $dir/crlnumber	# 必须注释掉当前的crl编号,以保留V1 crl
crl		= $dir/crl.pem 		# 当前CRL
private_key	= $dir/private/cakey.pem# 私钥x509_extensions	= usr_cert		# 要添加到证书的扩展名# 注释掉“传统的”(和高度破碎的)格式的以下两行。
name_opt 	= ca_default		# 主题名称选项
cert_opt 	= ca_default		# 证书字段选项# 扩展复制选项:小心使用。
# copy_extensions = copy# 要添加到CRL的扩展名。注意:Netscape communicator在V2 CRLs上会阻塞,因此默认情况下会注释掉这一点,留下V1 CRL。
# crlnumber也必须注释掉,以留下V1 CRL。
# crl_extensions	= crl_extdefault_days	= 365			# 认证需要多长时间
default_crl_days= 30			# 离下一个CRL还有多久
default_md	= sha384		# 使用默认公钥MD
preserve	= no			# 保持通过DN排序# 有几种不同的方式来指定请求看起来应该有多相似
# 对于类型CA,列出的属性必须相同,可选和提供的字段如下:-)
policy		= policy_anything# 对于CA策略
[ policy_match ]
countryName		= match
stateOrProvinceName	= match
organizationName	= match
organizationalUnitName	= match
commonName		= supplied
emailAddress		= optional# “任何事”政策
# 此时,您必须列出所有可接受的“对象”类型。
[ policy_anything ]
countryName		= optional
stateOrProvinceName	= optional
localityName		= optional
organizationName	= optional
organizationalUnitName	= optional
commonName		= supplied
emailAddress		= optional####################################################################
[ req ]
default_bits		= 4096
default_keyfile 	= privkey.pem
distinguished_name	= req_distinguished_name
attributes		= req_attributes
x509_extensions	= v3_ca	# 要添加到自签名证书的扩展名
default_md	= sha384		# 使用默认公钥MD# 如果没有私有密钥的密码,则会提示输入密码
# input_password = secret
# output_password = secret# 这将为允许的字符串类型设置一个掩码。有几种选择。
# 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 # 要添加到证书请求的扩展名[ 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	= GuangdonglocalityName			= Locality Name (eg, city)
localityName_default	 = Guangzhou0.organizationName		= Organization Name (eg, company)
0.organizationName_default	= Test Ltd.# 我们可以这样做,但通常不需要:-)
#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 ]# 当“ca”签署请求时,就会添加这些扩展。# 这违反了PKIX准则,但是一些CA这样做,一些软件需要这样做,以避免将最终用户证书解释为CA。basicConstraints=CA:FALSE# 下面是一些使用nsCertType的例子。
# 如果忽略了它,证书可以用于任何东西*除了*对象签名。# 这对于SSL服务器来说没有问题。
# nsCertType			= server# 对于对象签名证书,将使用此方法。
# nsCertType = objsign# 对于正常的客户端使用,这是典型的
nsCertType = client, email# 对于所有东西,包括对象签名:
# nsCertType = client, email, objsign# 这在客户端证书的密钥使用中是很典型的。
keyUsage = nonRepudiation, digitalSignature, keyEncipherment# 这将显示在Netscape的评论列表框中。
nsComment			= "我是client证书"# 如果包含在所有证书中,PKIX建议是无害的。
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer# 这个是subjectAltName和issuerAltname
# 导入邮箱地址
# subjectAltName=email:copy
# 一种生成根据PKIX不被弃用的证书的替代方法。
# subjectAltName=email:move# 本主题的细节
# issuerAltName=issuer:copy#nsCaRevocationUrl		= http://www.domain.dom/ca-crl.pem
#nsBaseUrl
#nsRevocationUrl
#nsRenewalUrl
#nsCaPolicyUrl
#nsSslServerName# 这是TSA证书所必需的。
extendedKeyUsage = clientAuth, emailProtection, timeStamping[ v3_req ]# 要添加到证书请求的扩展名basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment[ v3_ca ]
# 我是CA证书
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always,issuer
basicConstraints = CA:true
keyUsage = digitalSignature, keyCertSign, cRLSign
extendedKeyUsage = clientAuth, codeSigning, msEFS, emailProtection, ipsecTunnel, ipsecUser, OCSPSigning, serverAuth, timeStamping
nsCertType = sslCA, emailCA
nsComment = ""
subjectAltName = @ca_alt_names
issuerAltName = @ca_alt_names[ ca_alt_names ]
DNS.1 = Test Root CA
# IP.1 = 192.168.200.12[ v3_middle_ca ]
# 我是中间CA证书
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always,issuer
basicConstraints = CA:true, pathlen:0
keyUsage = digitalSignature, keyCertSign, cRLSign
nsComment = ""
subjectAltName = @middle_ca_alt_names
issuerAltName = @ca_alt_names[ middle_ca_alt_names ]
DNS.1 = Test Middle CA
# IP.1 = 192.168.200.12[ v3_server_ca ]
# 我是根CA颁发的服务器证书
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always,issuer
basicConstraints = CA:FALSE
keyUsage = digitalSignature, keyAgreement
extendedKeyUsage = clientAuth, serverAuth
nsComment = ""
subjectAltName = @server_alt_names
issuerAltName = @ca_alt_names[ v3_server_middle_ca ]
# 我是中间CA颁发的服务器证书
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always,issuer
basicConstraints = CA:FALSE
keyUsage = digitalSignature, keyAgreement
extendedKeyUsage = clientAuth, serverAuth
nsComment = ""
subjectAltName = @server_alt_names
issuerAltName = @middle_ca_alt_names[ server_alt_names ]
DNS.1 = *.test.com
DNS.2 = *.mytest.com
# IP.1 = 192.168.200.12[ crl_ext ]# CRL扩展。
# 只有issuerAltName和authorityKeyIdentifier在CRL中有意义。# issuerAltName=issuer:copy
authorityKeyIdentifier=keyid:always[ proxy_cert_ext ]
# 这些扩展应该在创建代理证书时添加# 这违反了PKIX准则,但是一些CA这样做,一些软件需要这样做,以避免将最终用户证书解释为CA。basicConstraints=CA:FALSE# 下面是一些使用nsCertType的例子。
# 如果忽略了它,证书可以用于任何东西*除了*对象签名。# 这对于SSL服务器来说没有问题。
# nsCertType			= server# 对于对象签名证书,将使用此方法。
# nsCertType = objsign# 对于正常的客户端使用,这是典型的
# nsCertType = client, email# 对于所有东西,包括对象签名:
# nsCertType = client, email, objsign# 这在客户端证书的密钥使用中是很典型的。
# keyUsage = nonRepudiation, digitalSignature, keyEncipherment# 这将显示在Netscape的评论列表框中。
nsComment			= "OpenSSL Generated Certificate"# 如果包含在所有证书中,PKIX建议是无害的。
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer# 这个是subjectAltName和issuerAltname。
# 导入邮箱地址。
# subjectAltName=email:copy
# 一种生成根据PKIX不被弃用的证书的替代方法。
# subjectAltName=email:move# 本主题的细节
# issuerAltName=issuer:copy#nsCaRevocationUrl		= http://www.domain.dom/ca-crl.pem
#nsBaseUrl
#nsRevocationUrl
#nsRenewalUrl
#nsCaPolicyUrl
#nsSslServerName# 要使它成为一个代理证书,这确实需要到位。
proxyCertInfo=critical,language:id-ppl-anyLanguage,pathlen:3,policy:foo####################################################################
[ tsa ]default_tsa = tsa_config1	# 默认的TSA部分[ tsa_config1 ]# 这些仅由TSA回复生成使用。
dir		= ./demoCA		# TSA根目录
serial		= $dir/tsaserial	# 当前序列号(必选)
crypto_device	= builtin		# 用于签名的OpenSSL引擎
signer_cert	= $dir/tsacert.pem 	# TSA签名证书(可选)
certs		= $dir/cacert.pem	# 回复中要包含的证书链(可选)
signer_key	= $dir/private/tsakey.pem # TSA私钥(可选)
signer_digest  = sha384			# 签名摘要要使用(可选)
default_policy	= tsa_policy1		# 如果request没有指定策略(可选)
other_policies	= tsa_policy2, tsa_policy3	# 可接受的政策(可选)
digests     = sha1, sha256, sha384, sha512  # 可接受的消息摘要(强制性的)
accuracy	= secs:1, millisecs:500, microsecs:100	# (可选)
clock_precision_digits  = 0	# 点后的位数(可选)
ordering		= yes	# 是否为时间戳定义了顺序? (可选, 默认值: no)
tsa_name		= yes	# 回复中必须包含TSA的名称吗? (可选, 默认值: no)
ess_cert_id_chain	= no	# 必须包括ESS证书id链吗? (可选, 默认值: no)
ess_cert_id_alg		= sha384	# 计算证书标识符的算法 (可选, 默认值: sha1)

生成证书


CA

openssl ecparam -genkey -name secp256k1 -out demoCA/private_key/ca-key_.key
openssl pkcs8 -topk8 -v2 aes-256-cbc -inform PEM -outform PEM -in demoCA/private_key/ca-key_.key -out demoCA/private_key/ca-key.key
openssl req -new -utf8 -config openssl.cnf -key demoCA/private_key/ca-key.key -subj "/C=CN/ST=Guangdong/L=Guangzhou/OU=Guangzhou Test Network Ltd./O=Guangzhou Test Network Ltd./CN=Test Network Root CA" -out demoCA/request/ca-req.csr
openssl x509 -req -extfile openssl.cnf -extensions v3_ca -days 730 -CAcreateserial -signkey demoCA/private_key/ca-key.key -in demoCA/request/ca-req.csr -out demoCA/certs/ca-cert.crt

Server

openssl ecparam -genkey -name secp256k1 -out demoCA/private_key/server-key_.key
openssl pkcs8 -topk8 -v2 aes-256-cbc -inform PEM -outform PEM -in demoCA/private_key/server-key_.key -out demoCA/private_key/server-key.key
openssl req -new -utf8 -config openssl.cnf -key demoCA/private_key/server-key.key -subj "/C=CN/ST=Guangdong/L=Guangzhou/OU=YQX Server/O=YQX Server/CN=*.yqx.com" -out demoCA/request/server-req.csr
openssl ca -utf8 -config openssl.cnf -extensions v3_server_ca -days 730 -create_serial -keyfile demoCA/private_key/ca-key.key -cert demoCA/certs/ca-cert.crt -in demoCA/request/server-req.csr -out demoCA/newcerts/server-cert.crt


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部