您当前的位置: 首页 >  ssl

暂无认证

  • 0浏览

    0关注

    92582博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

SSL基础:14:证书签发相关配置设定方法

发布时间:2019-12-12 07:35:54 ,浏览量:0

在这里插入图片描述 openssl.cnf是openssl命令的配置文件,很多证书签发和管理相关的设定都是在此配置文件中进行的,这篇文章介绍一下此配置文件常见的可设定的内容和方法。

设定文件的路径

文件路径:/etc/pki/tls/openssl.cnf

格式说明

格式说明: [ 段1名称 ] key1 = value1 key2 = value2

[ 段2名称 ] key3 = value3 key4 = value4

语法说明
  • 整体格式类似与脚本文件格式
  • 注释使用# 在行首设定
  • 在value的设定中可使用多行,\作为多行连接符使用
  • 在value的设定中可以识别\n等符号
  • 同段的值引用可以直接使用:${key1} 或者$key1
  • 跨段的值引用可以使用:${段1名称::key1} 或者 $段1名称:key1
  • 可以使用${ENV::环境变量} 方式引用系统环境变量,但系统环境变量不存在会出错
  • 段名可以进行自定义
  • 在开头的默认段也可以没有段名
  • 如果同一段内存在相同的key的设定,后面的会覆盖掉前面的值,openssl命令会使用最后的key的设定值
主要段和设定的说明 默认段
#[ default ]
HOME                    = .
RANDFILE                = $ENV::HOME/.rnd
设定项目 设定项目说明 HOME 定义HOME环境变量的默认值 RANDFILE 默认的随机种子文件,与-rand选项相对应 oid_section 扩展对象的定义,通过new_oids段进行保存和展开

使用技巧: 在读取配置文件时,首先会读取指定段的信息,如果没有找到就会到默认段来找。为了避免环境变量或者设定变量的不存在,可在默认段进行设定,比如缺省对HOME环境变量的设定。

new_oids段

new_oids严格来说是默认段的一部分,因为new_oids是oid_section设定项的值,具体oid_section的设定都在此段进行了实际的展开。可以在此段中添加ca、req或者ts子命令使用的扩展对象。使用示例如下所示:

testoid1=1.2.3.4

CA段
  • 缺省内容
[ ca ]
default_ca	= CA_default		# The default ca section

CA段主要是openssl ca子命令的设定选项的默认值来源,通过default_ca指定了CA_default来保存相关的设定,这也是ca子命令的-name选项的默认设定值。

CA_default段
  • 缺省内容
[ CA_default ]
dir		= /etc/pki/CA		# 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 ctificates 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 file
x509_extensions	= usr_cert		# The extentions 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_ext
default_days	= 365			# how long to certify for
default_crl_days= 30			# how long before next CRL
default_md	= sha256		# use SHA-256 by default
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
设定项目 设定项目说明 dir 保存所有信息的目录 certs 发行的证书的存放目录 crl_dir crl文件的存放目录 database 数据库索引文件 new_certs_dir 缺省存放新证书的目录,对应-outdir选项 certificate CA自身证书文件名,对应-cert选项 serial 存放当前序列号的文件,包含下一个可用的16进制数字 crlnumber 存放当前crl编号的文件 crl 存放当前crl的文件 private_key 存放CA自身私钥的文件名,对应-keyfile选项 RANDFILE 存放随机数的文件 x509_extensions 对应X.509扩展项的字段,对应extensions选项,在usr_cert段进行扩展 name_opt 当用户需要确认签发证书时的证书DN的显示格式,设定值与x509子命令的-nameopt选项相同 cert_opt 当用户需要确认签发证书时的证书域的显示格式,设定值与x509子命令的-certopt选项相同 default_days 新签发证书的默认有效期,单位为天,对应-dates、-startdate 、 -enddate选项 default_crl_days 当前CRL(证书吊销列表)到下次CRL发布的间隔天数,对应-crldays选项(default_crl_hours对应-crlhours选项) default_md 签发新证书或者CRL时使用的默认摘要算法 preserve 是否与证书请求中的参数顺序保持一致,设置为no时DN的参数顺序与证书策略的参数顺序一致,对应-preserveDN选项 policy 用于定义证书请求DN匹配策略,对应-policy选项,在policy_match段进行扩展 usr_cert段

主要用于设定X.509的扩展项信息

  • 缺省内容
[ 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
# 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
设定项目 设定项目说明 basicConstraints 基本约束,实际是为了标志当前签发的证书是否为CA证书,CA:FALSE表明为非CA证书,这种证书无法用来签发其他证书 keyUsage 证书的典型用途设定 nsComment 设定Netscape的comment listbox的显示信息 subjectKeyIdentifier PKIF工作组推荐设定,证书持有者的密钥标识符 authorityKeyIdentifier PKIF工作组推荐设定,颁发机构的密钥标识符 policy_match段

用于设定证书请求信息所需要匹配的策略,策略主要包含如下三种:

match: 需要证书请求和CA证书相应变量完全相同 supplied: 需要此项目在证书请求中提供 optional: 没有要求,可以在证书请求中提供,也可以不提供

  • 缺省内容
# For the CA policy
[ policy_match ]
countryName		= match
stateOrProvinceName	= match
organizationName	= match
organizationalUnitName	= optional
commonName		= supplied
emailAddress		= optional
设定项目 设定项目说明 countryName match策略 stateOrProvinceName match策略 organizationName match策略 organizationalUnitName optional策略 commonName supplied策略 emailAddress optional策略
关注
打赏
1653961664
查看更多评论
立即登录/注册

微信扫码登录

0.6213s