温馨提示×

Debian系统OpenSSL配置文件解析

小樊
40
2025-11-17 15:13:27
栏目: 云计算

在Debian系统中,OpenSSL的配置文件通常位于/etc/ssl/openssl.cnf

  1. [ ca ]:这一部分包含了证书颁发机构(CA)的配置信息。例如,CA的基本目录、证书有效期、证书序列号等。

  2. [ req ]:这一部分包含了证书请求(CSR)的配置信息。例如,请求的默认天数、默认的MD5摘要算法、默认的私钥文件等。

  3. [ v3_ca ]:这一部分包含了针对CA证书的扩展配置信息。例如,基本约束(basicConstraints)、密钥用法(keyUsage)等。

  4. [ v3_ext ]:这一部分包含了针对其他证书的扩展配置信息。例如,主题(subject)、颁发者(issuer)、有效期(notBefore和notAfter)等。

  5. [ v3_req ]:这一部分包含了针对证书请求的扩展配置信息。例如,基本约束(basicConstraints)、密钥用法(keyUsage)等。

  6. [ v3_intermediate_ca ]:这一部分包含了针对中间CA证书的扩展配置信息。例如,基本约束(basicConstraints)、密钥用法(keyUsage)等。

在配置文件中,可以使用注释来解释各个配置项的作用。注释以井号(#)开头,直到行尾。

以下是一个简单的OpenSSL配置文件示例:

# OpenSSL configuration file example

[ ca ]
default_ca = CA_default

[ CA_default ]
dir               = /etc/ssl/CA
certs             = $dir/certs
new_certs_dir     = $dir/newcerts
database          = $dir/index.txt
serial            = $dir/serial
RANDFILE          = $dir/private/.rand

[ req ]
default_bits        = 2048
prompt              = no
default_md          = sha256
distinguished_name  = req_distinguished_name
string_mask         = utf8only

[ req_distinguished_name ]
countryName                     = Country Name (2 letter code)
stateOrProvinceName             = State or Province Name
localityName                    = Locality Name
organizationName                = Organization Name
commonName                      = Common Name

[ v3_ca ]
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer
basicConstraints = critical, CA:true
keyUsage = critical, digitalSignature, cRLSign, keyCertSign

[ v3_req ]
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer
basicConstraints = critical, CA:false
keyUsage = critical, digitalSignature, keyEncipherment

[ v3_intermediate_ca ]
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer
basicConstraints = critical, CA:true
keyUsage = critical, digitalSignature, cRLSign, keyCertSign

这个示例配置文件包含了CA、证书请求、中间CA证书的基本配置。在实际使用中,可以根据需求对配置文件进行修改和扩展。

0