AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 916740
Accepted
d.lanza38
d.lanza38
Asked: 2018-06-15 13:19:25 +0800 CST2018-06-15 13:19:25 +0800 CST 2018-06-15 13:19:25 +0800 CST

本地 SSL CA 始终在创建后 30 天过期

  • 772

我正在按照与此答案类似的步骤来创建本地 CA。

尽管default_days在我的配置文件中将选项设置为 1825(天),但生成的 CA 证书始终设置为在创建后 30 天过期。

我通过查看生成的 PEM 文件来确认这一点 openssl x509 -in ./cacert.pem -text -noout

这是我用来创建 CA 证书的配置文件:

HOME            = .
RANDFILE        = $ENV::HOME/.rnd

####################################################################
[ ca ]
default_ca    = CA_default      # The default ca section

[ CA_default ]

default_days     = 1825         # how long to certify for
default_crl_days = 30           # how long before next CRL
default_md       = sha256       # use public key default MD
preserve         = no           # keep passed DN ordering

x509_extensions = ca_extensions # The extensions to add to the cert

email_in_dn     = no            # Don't concat the email in the DN
copy_extensions = copy          # Required to copy SANs from CSR to cert

base_dir      = ./CA
certificate   = $base_dir/cacert.pem        # The CA certifcate
private_key   = $base_dir/private/cakey.pem # The CA private key
new_certs_dir = $base_dir/newcerts          # Location for new certs after signing
database      = $base_dir/index.txt    # Database index file
serial        = $base_dir/serial   # The current serial number

unique_subject = no  # Set to 'no' to allow creation of
                     # several certificates with same subject.

####################################################################
[ req ]
default_bits       = 4096
default_keyfile    = cakey.pem
distinguished_name = ca_distinguished_name
x509_extensions    = ca_extensions
string_mask        = utf8only

####################################################################
[ ca_distinguished_name ]
countryName         = Country Name (2 letter code)
countryName_default = US

stateOrProvinceName         = State or Province Name (full name)
stateOrProvinceName_default = CA

localityName                = Locality Name (eg, city)
localityName_default        = Bakersfield

organizationName            = Organization Name (eg, company)
organizationName_default    = Some Company

organizationalUnitName         = Organizational Unit (eg, division)
organizationalUnitName_default = Some Org Unit

commonName         = Common Name (e.g. server FQDN or YOUR name)
commonName_default = some-local-CA

emailAddress         = Email Address
emailAddress_default = [email protected]

####################################################################
[ ca_extensions ]

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

####################################################################
[ signing_policy ]
countryName            = optional
stateOrProvinceName    = optional
localityName           = optional
organizationName       = optional
organizationalUnitName = optional
commonName             = supplied
emailAddress           = optional

####################################################################
[ signing_req ]
subjectKeyIdentifier   = hash
authorityKeyIdentifier = keyid,issuer
basicConstraints       = CA:FALSE
keyUsage               = digitalSignature, keyEncipherment

然后我使用此命令(同一目录)创建本地 CA:

openssl req -x509 -config ./openssl-ca.cnf -newkey rsa:4096 -sha256 -nodes -out cacert.pem -outform PEM

我尝试将default_crl_days选项设置为 30 以外的值,但似乎没有任何效果。

如何指定本地 CA 的到期日期(或到期前的天数)?

ssl
  • 2 2 个回答
  • 2927 Views

2 个回答

  • Voted
  1. Best Answer
    slm
    2018-06-15T15:47:11+08:002018-06-15T15:47:11+08:00

    通过生成 CA 和 CA-INT 的设置,我的有效期得到以下信息:

       Validity
            Not Before: Jan 28 03:28:40 2018 GMT
            Not After : Jan 23 03:28:40 2038 GMT
    

    我开始发现,我只能通过openssl直接通过-days开关将其传递给它来使其工作。

    例如:

    openssl req -config $topDir/openssl.cnf \
          -key $ca_key_file \
          -new -x509 -days 7300 -sha256 -extensions v3_ca \
          -out $ca_cert_file -passin pass:casecret \
          -subj "/C=US/ST=NC/L=Raleigh/O=APPS Security/OU=APPS/CN=APPS CA"
    
    • 3
  2. garethTheRed
    2018-06-15T22:48:10+08:002018-06-15T22:48:10+08:00

    如果您按照链接的问题/答案进行操作,则海报将openssl req用于生成证书。如果命令行上没有特定-days选项,该命令默认为 30 天:

    -天数

    当使用 -x509 选项时,它指定认证证书的天数,否则将被忽略。n 应该是一个正整数。默认值为 30 天。

    命令也是如此x509:

    -天参数

    指定使证书有效的天数。默认值为 30 天。

    default_days,default_startdate并且default_enddate在选项文件中仅与openssl ca命令一起使用(不是req或x509)。

    • 1

相关问题

  • 如何使用 Tomcat 5.5 更新 SSL 证书

  • 为 IIS6 自行生成 SSL 证书?

  • plesk 上的域和子域 ssl 访问

  • 如何设置 SSL 邮件服务器?

  • 如何通过 SVN 命令行接受 SSL 证书?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve