如何将自签名的openssl x509证书添加到Tomcat

时间:2012-02-15 22:23:36

标签: tomcat openssl x509

我创建了我的证书如下;

openssl req -nodes -new -text -out ~/server.req -keyout ~/server.key

openssl req -x509 -in ~/server.req -text -key ~/server.key -out ~/server.crt

我现在需要将它添加到Tomcat,显然我不能使用

的Tomcat文档示例

openssl pkcs12 -export -in server.crt -inkey server.key -out server.p12 -name tomcat -CAfile serverCA.crt -caname root -chain

因为它是自签名的。那么如何将其添加到Tomcat?

2 个答案:

答案 0 :(得分:0)

Tomcat文档中提供的示例将起作用,您只需创建自己的本地证书颁发机构即可创建证书。

我发现本教程过去很有用:http://gagravarr.org/writing/openssl-certs/ca.shtml

该页面的以下命令:

openssl genrsa -des3 -out CA.key <key_size>
openssl req -new -key CA.key -x509 -days 1095 -out ../certs/CA.crt

使用CA.crt标志创建证书时-CAfile将使用的内容

希望有所帮助。

答案 1 :(得分:0)

我找到了我的旧笔记。

您无法使用自签名证书。你需要做的是走更长的路线并生成一个“真正的”本地CA,如下所示:

为CA生成私钥

openssl genrsa -out CA/cakey.pem -des3 2048

为根CA证书生成证书签名请求

openssl req -new -config openssl.cnf -key CA/cakey.pem -out CA/cacert.req

自我签署CA证书

openssl x509 -req -in CA/cacert.req -extfile openssl.cnf \
    -extensions v3_ca -signkey CA/cakey.pem -out CA/cacert.pem -days 3650

生成包含客户端CA证书的Java密钥库:

keytool -importcert -file CA/cacert.pem -keystore client.jks -storepass [password]
相关问题