McL*_*vin 5 java certificate keystore truststore private-key
使用keytool,我试图在我拥有的密钥库中扩展trustedCertEntry的到期日期.密钥库具有以下内容
$ keytool -list -keystore certs/authTruststore.jks
Enter keystore password:
Keystore type: JKS
Keystore provider: SUN
Your keystore contains 3 entries
sts, Nov 11, 2013, trustedCertEntry,
Certificate fingerprint (SHA1): 8D:33:B7:69:DE:75:8F:22:E2:95:2C:EB:93:65:41:31:42:A6:E3:A7
__
localhost, Nov 11, 2013, PrivateKeyEntry,
Certificate fingerprint (SHA1): F4:A9:84:1E:7F:BF:5D:71:58:74:E4:C6:00:49:37:49:38:3E:31:BE
__
security_localhost, Nov 11, 2013, trustedCertEntry,
Certificate fingerprint (SHA1): 6B:F8:E1:36:EB:36:D4:A5:6E:A0:5C:7A:E4:B9:A4:5B:63:BF:97:5D
Run Code Online (Sandbox Code Playgroud)
我可以成功修改第二个条目的过期日期,类型为PrivateKeyEntry的localhost但是当尝试使用相同的命令修改其他两个的过期时,我收到以下错误:
$ keytool -selfcert -v -alias security_localhost -validity 3650 -keystore certs/authTruststore.jks -storepass ****
keytool error: java.lang.Exception: Alias <localhost> has no key
java.lang.Exception: Alias <localhost> has no key
at sun.security.tools.KeyTool.recoverKey(KeyTool.java:3095)
at sun.security.tools.KeyTool.doSelfCert(KeyTool.java:2442)
at sun.security.tools.KeyTool.doCommands(KeyTool.java:1071)
at sun.security.tools.KeyTool.run(KeyTool.java:340)
at sun.security.tools.KeyTool.main(KeyTool.java:333)
Run Code Online (Sandbox Code Playgroud)
我该如何延长这些到期日期?
看看这个链接。它说,
Generates an X.509 v1 self-signed certificate, using keystore information including
the private key and public key associated with alias
Run Code Online (Sandbox Code Playgroud)
因此,您可以使用与密钥关联的-selfcert更新证书。您的first和third是受信任的证书条目,其中您的second条目是 PrivateKeyEntry。该条目的证书与其相关联PrivateKey。而其他两个则不然。
如果这 2 个证书已过期,您只能以与最初将它们添加到密钥库相同的方式更新为最新证书。通过执行-importcert。
注意:-selfcert现已过时。你可以在这里读更多关于它的内容。