OpenSSL 未签名证书静默

发布于 2024-12-27 21:11:18 字数 599 浏览 1 评论 0 原文

遇到了麻烦——还有其他一些相关的帖子,但没有那么具体。我正在尝试为开发机器默默地生成证书。这些是我最初运行的命令,但被要求输入密码:

openssl genrsa -des3 -out server.key 1024
openssl req -new -key server.key -out server.csr
openssl x509 -req -days 1024 -in server.csr -signkey server.key -out server.crt

下面的第一个命令有效,但第二个命令不太有效。我看到了 passin 选项,但遇到了麻烦,因为系统仍然要求我输入密码。

openssl genrsa -des3 -passout pass:$passphrase -out server.key 1024
openssl req -passout pass:$passphrase -new -key server.key -out server.csr
openssl x509 -req -days 1024 -in server.csr -signkey server.key -out server.crt

Having trouble with this -- a couple of other related posts out there, but nothing so specific. I'm trying to silently generate certs for a dev machine. These are the commands I originally ran, but was asked for a passphrase:

openssl genrsa -des3 -out server.key 1024
openssl req -new -key server.key -out server.csr
openssl x509 -req -days 1024 -in server.csr -signkey server.key -out server.crt

The first command below works, but the second doesn't quite work. I see the passin option, but am having trouble, as I'm still getting asked for a passphrase.

openssl genrsa -des3 -passout pass:$passphrase -out server.key 1024
openssl req -passout pass:$passphrase -new -key server.key -out server.csr
openssl x509 -req -days 1024 -in server.csr -signkey server.key -out server.crt

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

陈独秀 2025-01-03 21:11:18
$ openssl genrsa -out server.key 1024
$ touch openssl.cnf
$ cat >> openssl.cnf <<EOF
[ req ]
prompt = no
distinguished_name = req_distinguished_name

[ req_distinguished_name ]
C = GB
ST = Test State
L = Test Locality
O = Org Name
OU = Org Unit Name
CN = Common Name
emailAddress = [email protected]
EOF
$ openssl req -config openssl.cnf -new -key server.key -out server.csr
$ openssl x509 -req -days 1024 -in server.csr -signkey server.key -out server.crt
$ openssl genrsa -out server.key 1024
$ touch openssl.cnf
$ cat >> openssl.cnf <<EOF
[ req ]
prompt = no
distinguished_name = req_distinguished_name

[ req_distinguished_name ]
C = GB
ST = Test State
L = Test Locality
O = Org Name
OU = Org Unit Name
CN = Common Name
emailAddress = [email protected]
EOF
$ openssl req -config openssl.cnf -new -key server.key -out server.csr
$ openssl x509 -req -days 1024 -in server.csr -signkey server.key -out server.crt
香草可樂 2025-01-03 21:11:18

适用于 Windows 的解决方案。使用以下内容创建批处理文件 (start-https-server.bat):

@echo off

if not exist ".\openssl.cnf" (
    @echo [ req ] > openssl.cnf
    @echo prompt = no >> openssl.cnf
    @echo distinguished_name = req_distinguished_name >> openssl.cnf
    @echo [ req_distinguished_name ] >> openssl.cnf
    @echo C = IE >> openssl.cnf
    @echo ST = Test State >> openssl.cnf
    @echo L = Test Locality >> openssl.cnf
    @echo O = Org Name >> openssl.cnf
    @echo OU = Org Unit Name >> openssl.cnf
    @echo CN = Common Name >> openssl.cnf
    @echo emailAddress = [email protected] >> openssl.cnf

    openssl req -newkey rsa:2048 -new -nodes -keyout key.pem -out csr.pem -config openssl.cnf
    openssl x509 -req -days 365 -in csr.pem -signkey key.pem -out cert.pem
)

将以下内容添加到批处理文件的末尾,以使用节点的 http-server 打开站点 (https://www.npmjs.com/package/http-server)。

http-server -S -o

警告:这仅适合开发。

Solution for Windows. Create a batch file (start-https-server.bat) with the following:

@echo off

if not exist ".\openssl.cnf" (
    @echo [ req ] > openssl.cnf
    @echo prompt = no >> openssl.cnf
    @echo distinguished_name = req_distinguished_name >> openssl.cnf
    @echo [ req_distinguished_name ] >> openssl.cnf
    @echo C = IE >> openssl.cnf
    @echo ST = Test State >> openssl.cnf
    @echo L = Test Locality >> openssl.cnf
    @echo O = Org Name >> openssl.cnf
    @echo OU = Org Unit Name >> openssl.cnf
    @echo CN = Common Name >> openssl.cnf
    @echo emailAddress = [email protected] >> openssl.cnf

    openssl req -newkey rsa:2048 -new -nodes -keyout key.pem -out csr.pem -config openssl.cnf
    openssl x509 -req -days 365 -in csr.pem -signkey key.pem -out cert.pem
)

Add the following to the end of the batch file to open the site using node's http-server (https://www.npmjs.com/package/http-server).

http-server -S -o

Caveat: this is only suitable for development.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文