我使用这三个语句来生成带有我拥有的根证书的自签名证书。
openssl genrsa -out domain.org.key
openssl req -newkey rsa:2048 -nodes -keyout domain.org.key -subj "/C=CN/ST=GD/L=SZ/O=Acme, Inc./CN=*.domain.org" -out domain.org.csr
openssl x509 -req -extfile <(printf "subjectAltName=DNS:domain.org,DNS:www.domain.org") -days 1 -in domain.org.csr -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out domain.org.crt
然而,在这里,有效期只能更改一天。有没有人知道我是否可以添加一个参数,使我可以将开始日期和结束日期更改为秒或分钟的粒度。出于测试目的,我需要创建几个有效期只有几分钟的证书。我看过其他答案,他们建议使用ca
命令:
openssl ca -config /path/to/myca.conf -in req.csr -out ourdomain.pem \
-startdate 0801010000Z -enddate 1001010000Z
但我不确定如何组合这两个命令,因为第二个命令似乎只是生成域的密钥。是否有人可以帮助组合这两个命令,或者以其他方式更改cert时间,而不涉及更改系统时间。
发布于 2019-01-25 01:43:46
openssl命令行不提供命令行选项来设置"x509 -req“选项的开始和结束日期。
如果您确实需要这样做,您可以修改openssl源代码以执行您想要的操作。
在app\req.c中,您需要修改"set_cert_times“调用:
if (days == 0) {
/* set default days if it's not specified */
days = 30;
}
if (!set_cert_times(x509ss, NULL, NULL, days))
goto end;
int set_cert_times(X509 *x, const char *startdate, const char *enddate,
int days)
如果您提供了startdate和enddate,它将覆盖days参数,因此您可以执行以下操作:
if (!set_cert_times(x509ss, "0801010000Z", "1001010000Z", days))
goto end;
这将对开始和结束日期进行硬编码,或者只需多做一点工作,就可以在x509 -req处理中添加对-startdate和-enddate参数的支持。
https://stackoverflow.com/questions/54352034
复制相似问题