java keystore with no password...

Status
Not open for further replies.

kperrier

Ars Legatus Legionis
21,511
So, a client wants us to use a client cert to authenticate to their web service. They sent it to me in pkcs12 format but without a password. (This is for their uat site, the prod pkcs12 file has a password.) I am trying to create a java keystore file for this cert and the process is bombing out. All indications are that the failure is due to an incorrect or no password when attempting to read the pfx file. I can use the keytool command
Code:
keytool -v -list -storetype pkcs12 -keystore uat.pfx
to list the contents of the file just fine. It is just when I attempt to create the JKS file it fails:
Code:
$ keytool -importkeystore -srckeystore uat.pfx \
-srcstoretype pkcs12 -srcalias key-alias -destkeystore uat.jks \
-deststoretype jks -deststorepass "" -destalias UAT
keytool error: java.lang.Exception: Keystore password must be at least 6 characters
If I leave out the -deststorepass and enter it as empty on the command line I get the same error.

Openssl barfs on this too, I think due to the fact that there isn't a password on the pfx file, when I try to convert it to PEM format.

Is there anything I can do here other than ask for the UAT cert to be sent again, either with a password or in a different format? I am able to create a KJS file for the prod cert without out a problem, as long as I use the same password for the kjs file.

Web pages I have found in trying to solve this:
http://stackoverflow.com/questions/1541 ... ng-openssl
http://stackoverflow.com/questions/4217 ... rivate-key

Thanks!
 
[url=http:/civis/viewtopic.php?p=28263617#p28263617:3j3y6wll said:
kperrier[/url]":3j3y6wll]Yeah, and if there is no password on the PKCS12 file then you can't create the JKS file. At least that is what my experience has shown me...

You can use PKCS12 directly as a Keystore and pass it in. See http://docs.oracle.com/javase/7/docs/ap ... Store.html and use
Code:
KeyStore ks = KeyStore.getInstance("pkcs12");

as the keystore type.

Not only that, you're doing client authentication, which uses private keys. I don't think you can use private keys with JKS -- the note says "Storing trusted anchors in PKCS12 is not supported. Users should store trust anchors in JKS format and save private keys in PKCS12 format."

http://docs.oracle.com/javase/7/docs/te ... ml#SunJSSE
http://blog.palominolabs.com/2011/10/18 ... keystores/
 
Status
Not open for further replies.