How to convert from .pem to .p12
More specifically; how to read privkey.pem file and fullchain.pem file and convert that into a byte array with the format of p12 in java. (I know there's somehing called OpenSSL which can do this.
I found a guide online which uses he BouncyCastle library to do this, the issue is that these solutions does not work on the latest version because of api changes.
For even more context: I have certbot and that produces .pem files. I have written a simple server in jersey, which I want to be able to establish https connections with. But that does not seem to support .pem files, but rather .p12 files. Simple solution to this is to convert the files manually, but that will not be sustainable in the longrun, thus my question.
10 Replies
⌛
This post has been reserved for your question.
Hey @Thorinwasher! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
Why is he unit testing tag here?
Whops
Convert a PEM Certificate to PFX/P12 format
PEM certificates are not supported, they must be converted to PKCS#12 (PFX/P12) format.
When I think about it, I could run an openssl process with java to convert the files to .p12, to then use that file for setting up the https server
So that's one solution, but it would be better if I could just convert between the two formats without having to store a file, maybe that's too much to ask though. I will keep this open as I'm hoping for a less messy solution
I am not sure but openssl should have an option to read files from standard input and write them to std out
If so you could read the converted file directly from process's output
which file would you need to store?
.
you can also do something like https://stackoverflow.com/a/9839841/10871900 if you want to do it from Java code
Stack Overflow
Convert SSL .pem to .p12 with or without OpenSSL
I get external .pem files that need to be converted to .p12 files - I add a username and password in the process. (I need to do this to utilize a third party API.)
Using openssl, the command is....
Oh O_O, then that definitely is an option. Thanks for the help!
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Post Closed
This post has been closed by <@270177852157067264>.