0

这个问题可能是重复的,但我无法获得解决方案,我尝试使用以下命令创建 SSL 证书,

C:\Program Files\Java\jdk1.6.0_05\bin>keytool -genkey -alias tomcat -keyalg RSA
-keystore E:\key
Enter keystore password:
Re-enter new password:
What is your first and last name?
  [Unknown]:  Raghu
What is the name of your organizational unit?
  [Unknown]:  BFS
What is the name of your organization?
  [Unknown]:  iGate
What is the name of your City or Locality?
  [Unknown]:  Bang
What is the name of your State or Province?
  [Unknown]:  KA
What is the two-letter country code for this unit?
  [Unknown]:  IN
Is CN=Raghu, OU=BFS, O=iGate, L=Bang, ST=KA, C=IN correct?
  [no]:  y

Enter key password for <tomcat>
        (RETURN if same as keystore password):
Re-enter new password:

我尝试使用以下命令获取证书请求

C:\Program Files\Java\jdk1.6.0_05\bin>keytool -certreq -v -alias tomcat -keyalg
RSA -keystore E:\key
Enter keystore password:

并在命令提示符下得到以下响应

**-----BEGIN NEW CERTIFICATE REQUEST----- MIIBlzCCAQACAQAwVzELMAkGA1UEBhMCSU4xCzAJBgNVBAgTAktBMQ0wCwYDVQQHEwRCYW5nMQ4w
DAYDVQQKEwVpR2F0ZTEMMAoGA1UECxMDQkZTMQ4wDAYDVQQDEwVSYWdodTCBnzANBgkqhkiG9w0B
AQEFAAOBjQAwgYkCgYEA0Aoxz2V/Cqs00d7d4iVysIcfMxXDA4ydD5+AY2Q2hPqIOAbfrz0HiSjZ
JwKV0/g7P/oWPU9fCFYnLXAynusbaAtw5xIolMNqj9gtxmD1BzrwxcVIX3oWY0LzO768TMY3Szjp
tS64z5q1KSTYqeZww0f11N2JssjtMch8gw50FIcCAwEAAaAAMA0GCSqGSIb3DQEBBQUAA4GBAK1v
sE0BNxGrGKNBXhYuSdgwF14ZnELtjWBzDJDzbzgJbK6RJlOEstKxdStR2fq7iv0ow+Df7TnVWidm
+0PRLuhtr3DMZVX2acNQY4c4ynKWgLyBV2lAXbYfgZdzQr3ClY+40lkbmHQaMxZcxz2q7u8Np6sH
n0iytY6U0CqJpRcB
----END NEW CERTIFICATE REQUEST-----**

我保存在 cert.txt 文件中并验证证书回复

 C:\Program Files\Java\jdk1.6.0_05\bin>keytool -printcert -file E:\cert.txt

**keytool error: java.lang.Exception: Failed to parse input**

我得到了上述错误。请提出相同的建议。

4

2 回答 2

4

您混淆了证书证书请求

当您使用 时-certreq,您正在生成一个证书请求 (CSR),您应该将其发送给您的 CA,CA 将向您发送一个证书作为回报。然后,您将能够将该证书导入您的密钥库,针对它已经拥有的私钥(并且使用-genkey.

-printcert用于打印证书,而不是证书请求 ( BEGIN NEW CERTIFICATE REQUEST)。

于 2013-07-18T14:06:16.727 回答
1

我认为您错过了导致问题的一步。

keytool -exportcert -rfc -keystore D:\key -file D:\cert.crt 

请检查此链接

于 2013-07-22T10:46:06.157 回答