问题
I am using jdk 1.6 in Windows. I have a .der file (DER Encoded X509 Certificate) that will like to add to my cacerts file... so I tried the following:
keytool -import -keystore "C:\Program Files\Java\jdk1.6.0_27\jre\lib\security\cacerts" -trustcacerts -alias openldap -file "C:\cacert.der"
I got the following error: java.security.cert.CertificateParsingException: java.io.IOException: subject key, java.security.spec.InvalidKeySpecException: Unknown key spec
At first, I thoght it was a problemen with the der certificate, but then doing the following I got exactly the same error:
keytool -list -keystore "C:\Program Files\Java\jdk1.6.0_27\jre\lib\security\cacerts"
Any ideas why is this problem appearing? I have not found anything in the Web. Thanks in advance.
回答1:
I faced same issue while opening cacert for listing the certificates. There was a file permission issue on my machine. I tried with root user.It was working. I resolved error by adding new jdk jre with proper permission.
回答2:
You may have two or more jdk's installed on your machine. One thing, which you can try, is go to your target jdk. In your case it is
C:\Program Files\Java\jdk1.6.0_27\bin
Then run your command, Once it is working, then make sure that your PATH variable is configured properly to the targeted JDK's bin.
来源:https://stackoverflow.com/questions/7931144/error-adding-certificate-to-cacerts-unknown-key-spec