kurtbrose / pyjks

a pure python Java KeyStore file parser, including private key decryption
MIT License
130 stars 35 forks source link

Exception: Not a JKS or JCEKS keystore (magic number wrong; expected FEEDFEED or CECECECE) #51

Closed singhmousam closed 5 years ago

singhmousam commented 5 years ago

I followed these steps to generate jks file: openssl pkcs12 -export -in private.crt -inkey server.key -out ik.p12

keytool -importkeystore -deststorepass mks@1 -destkeystore msnew.jks -srckeystore ik.p12 -srcstoretype PKCS12

And on importing this jks file in python it is throwing I do not understand it's reason.

mahmoud commented 5 years ago

You've created a PKCS12 file (.p12), not a JKS. Seems like that's the emerging recommendation, but you'll need a different library (pyjks only supports jks). See also #49 for a bit more info.

singhmousam commented 5 years ago

@mahmoud The source is PKCS12 file and it is being converted to jks file. If this is the incorrect way please tell in what way will I get a jks file from certificate and private key.

mahmoud commented 5 years ago

Depends on the version of keytool, I guess. I think the default destination keystore type changed to p12 lately. You probably need a flag like -deststoretype jks, which I notice is missing from your command. Give that a shot.

singhmousam commented 5 years ago

Yes I already tried that too, but that's again throwing the same error. I don't understand what's the issue with it.