I am using pyjks to read a jks file and find private key for further encryption. It is quite easy in Windows system but I am not able to figure out what should be done if we are on linux environment. I have a self-signed certificate, from that I have extracted private key and public certificate. Now I need to store it in keystore of linux, that java keystore will further be read by a python script to fetch private key and do the decryption.
openssl pkcs12 -export -in private.crt -inkey server.key -out ks.p12
keytool -importkeystore -deststorepass psswrd -destkeystore msnew.jks -deststoretype JKS -srckeystore ks.p12 -srcstoretype PKCS12
Python Code:
keystore = jks.KeyStore.load('/home/ikscare/Documents/Projects/Subu/crypto/msnew.jks', passphrase)
Exception thrown is : BadKeystoreFormatException: Not a JKS or JCEKS keystore (magic number wrong; expected FEEDFEED or CECECECE)