我正在开发一个在 Glassfish 上与 Jersey 一起运行的 REST 服务器,我想让它在 localhost 上的 HTTPS 上运行。
我找到了许多用于生成 CA 证书的教程,其他用于生成 .cer / .crt / .key / .csr / ... 文件的教程,其他用于生成 jks 密钥库的教程。
但他们没有回答我的(非常基本的)问题:如何生成自签名证书并将其用于在本地主机上的 Glassfish 上运行的我的应用程序中?从头开始到真正使用的集成,无需任何具有 crt、jks 或任何其他文件的先决条件。
(有关信息,我使用 Linux)
谢谢
编辑:我终于用以下命令创建了一个证书
openssl req -x509 -out localhost.crt -keyout localhost.key \
-newkey rsa:2048 -nodes -sha256 \
-subj '/CN=localhost' -extensions EXT -config <( \
printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")
openssl pkcs12 -export -name localhostServerCert -in localhost.crt -inkey localhost.key -out localhostP12Keystore.p12
keytool -importkeystore -destkeystore localhostKeystore.jks -srckeystore localhostP12Keystore.p12 -srcstoretype pkcs12 -alias localhostServerCert
copy localhostKeystore.jks into /glassfish/domains/domain1/config
keytool -importkeystore -srckeystore localhostKeystore.jks -destkeystore keystore.jks
我已经在管理控制台中使用证书昵称修改了 http-listener-2 localhostServerCert
,但是在 https://localhost:8181 (ERR_CONNECTION_REFUSED) 上出现错误页面
编辑2:我认为证书应该有问题,因为openssl s_client -showcerts -connect localhost:8181
退货no peer certificate available
,No client certificate CA names sent