Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JKS file generated is more than 3 fold in size compare to same file creation using keytool #44

Open
shivgit87 opened this issue Sep 14, 2018 · 6 comments

Comments

@shivgit87
Copy link

HI Team ,

I am generating keystore using keytool iam getting jks file with size 3kb.But I am using the same procedure to generate using Jks I am getting file size as 10kb. May I know the reason.

Thanks and Regards,
Shivakumar

@magnuswatn
Copy link
Contributor

Hi,

That sounds odd. What do you have inside the jks? Only key and certificate, or a chain as well? How long is the chain? Can you share?

Thanks.

@shivgit87
Copy link
Author

shivgit87 commented Sep 17, 2018 via email

@magnuswatn
Copy link
Contributor

Can you share your code for creating the jks?

@shivgit87
Copy link
Author

shivgit87 commented Sep 25, 2018 via email

@magnuswatn
Copy link
Contributor

You can't import the certificates and key in PEM format directly into the jks keystore. You must decode them into binary/DER first.

Using pyopenssl you can do like this:

loaded_cert = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, cert)
loaded_key = OpenSSL.crypto.load_privatekey(OpenSSL.crypto.FILETYPE_PEM, pk)

dumped_cert = OpenSSL.crypto.dump_certificate(OpenSSL.crypto.FILETYPE_ASN1, loaded_cert)
dumped_key = OpenSSL.crypto.dump_privatekey(OpenSSL.crypto.FILETYPE_ASN1, loaded_key)

I'm guessing that's your problem - base64 encoding is less efficient and will increase the size of the keystore (in addition to making it useless).

@shivgit87
Copy link
Author

shivgit87 commented Sep 26, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants