如何使用keytool生成私钥证书

时间:2013-03-22 13:40:36

标签: java ssl ssl-certificate keytool

我正在尝试使用私有密钥生成带有私钥的keytool的证书吗?

1.   Generate private key, public key and keystore to store the keys.



       /usr/local/packages/jdk16/bin/keytool -genkeypair -keyalg RSA -validity 300 -alias sslcert -keystore weblogic.jks

2. Create self signed certificate

    /usr/local/packages/jdk16/bin/keytool -selfcert -keyalg RSA -alias sslcert -keystore weblogic.jks

3.  Export the self signed certificate to a file

$ `/usr/local/packages/jdk16/bin/keytool -export -alias sslcert -rfc -file ohs.crt -keystore weblogic.jks`
      Enter keystore password: 
      Certificate stored in file <ohs.crt>

当我尝试导入该证书时,它说

Error in installing the server certificate.
 No private key found.

1 个答案:

答案 0 :(得分:0)

导出的证书不包含私钥。私钥保留在密钥库中。您似乎使用长手方式来复制密钥库。只需将密钥库复制到服务器即可。实际上它应该已经 at 服务器,否则你可能会泄露私钥。