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
JavaBot
JavaBot8mo ago
This post has been reserved for your question.
Hey @Thorinwasher! Please use /close or the Close 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.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Thorinwasher
ThorinwasherOP8mo ago
Why is he unit testing tag here? Whops
Thorinwasher
ThorinwasherOP8mo ago
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
Defective
Defective8mo ago
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
dan1st
dan1st8mo ago
which file would you need to store? .
dan1st
dan1st8mo ago
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....
Thorinwasher
ThorinwasherOP8mo ago
Oh O_O, then that definitely is an option. Thanks for the help!
JavaBot
JavaBot8mo ago
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.
JavaBot
JavaBot8mo ago
Post Closed
This post has been closed by <@270177852157067264>.
Want results from more Discord servers?
Add your server