Posts Tagged ‘signed’

How to convert .p12 ssl certificate to .pem with openssl command

Friday, March 21st, 2025

In cryptography, PKCS #12 defines an archive file format for storing many cryptography objects as a single file. It is commonly used to bundle a private key with its X.509 certificate or to bundle all the members of a chain of trust.

A PKCS #12 file may be encrypted and signed. The internal storage containers, called "SafeBags", may also be encrypted and signed. A few SafeBags are predefined to store certificates, private keys and CRLs. Another SafeBag is provided to store any other data at individual implementer's choice.

PKCS #12 is one of the family of standards called Public-Key Cryptography Standards (PKCS) published by RSA Laboratories.

Privacy-Enhanced Mail (PEM) is a de facto file format for storing and sending cryptographic keys, certificates, and other data, based on a set of 1993 IETF standards defining "privacy-enhanced mail." While the original standards were never broadly adopted and were supplanted by PGP and S/MIME, the textual encoding they defined became very popular. The PEM format was eventually formalized by the IETF in RFC 7468.

If you already have a .P12 certificate password signed provided by someone and you need to convert it a .PEM, this can be done like so:

To convert .p12 certificate :

# Initialize variable
cert_p12_in=your-domain-name-cert.p12
cert_p12_pass='XXXZZZYYYPPPQQQ'
cert_pem_out=your-domain-name-cert.pem
 
 
# Extract the private key
openssl pkcs12 -in $cert_p12_in -nocerts -nodes -passin "pass:$cert_p12_pass" 2>/dev/null | sed -ne '/-BEGIN PRIVATE KEY-/,/-END PRIVATE KEY-/p' > $cert_pem_out
 
# Extract the certificate
openssl pkcs12 -in $cert_p12_in -clcerts -nokeys -passin "pass:$cert_p12_pass" 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' >> $cert_pem_out
 
# Extract the Chain certificate, potentially nothing
openssl pkcs12 -in $cert_p12_in -cacerts -nokeys -chain  -passin "pass:$cert_p12_pass" 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' >> $cert_pem_out
 
# Display the result
cat $cert_pem_out

That's all you should have the .p12 to .pem successfully converted.
Cheers ! 🙂

A registered mail (Signed letter mail)

Tuesday, April 7th, 2009

Today I almost cracked down. The story is quite long. It’s about sendinga registered letter mail. I realized on Thursday. That the address I wrote to the skype of my sis was missing the postbox number. I prayed on Saturday and Sunday a bit to God to fix up the whole situation. On Monday I decided to Go to the local TNT and ask if the registered letter has arrived. They told me nothing has arrived for Honigkamp 2. That is The address where I live. They gave me a number told me I should call and ask how to proceed ih my case and what is the standard procedure. I called to Sali to ask him if he knows what I’m supposed to do. He suggested that we went to the TNT central post office and ask. I asked him if it is convenient for him to go to his home around 14:00 or 15:00. Then I went to school to the auditorium we had some lectures scheduled with M. Mayers our counseling teacher was there. After completing the Belbin Team Roles test in order to find out which person is most suitable for what kind of function in our 17 people group. Brian the project manager assisstent revealed us how to interpret the results from the test. According to the test I am suitable as implementer a Shaper and Resource-Evaluator mostly. Then we did an interesting exercise where we split in two groups and we had the assignment in which there were 6 people occupying different role in society and in a different age. We had to select which 3 of them are we going to save and decide this as a group. This should be counted as a team building session, it was quite interesting and scary. Because I realized some day I might face the same dilemma in some form and then I had to decide for real God forbid. Then I went to the school library and I worked on my Design.BG report I had to fix some minor things to align it with the fixed version of the report. Oh yes not to forget, big thanks to Nomen (Mitko) and Niki( lunarstill) for checking out the report for errors and coloring the erroneous things in red. Then I went to Sali, like we have spoken earlier. He wasn’t there. I had a couple of emails to write related to my work as sys-admin. Then Mimi (Sali’s wife) treated me with a coffee :). Then I called to Sali to ask him if he is coming soon. He proposed to meet near Aktion. So I took the bike of her nephew (a girlish one) and went to the city center. They were drinking coffee there with Koko’s father (Bat Birio). We tried to reach for the city center post but it was closed. I tried to call the number they gave me earlier in the morning in TNT post and spoke with the guys. But however that wasn’t really helpful. What I got from them is that my parents need to request for investingation of the letter. I was on my way to get really angry. I tried to explain to an old Dutch man who happily spoke some English my problem and ask him to help ‘coz he knows dutch. He hardly grasped what I mean, so I had to explain it again and again numerous times, that truely irritated me. Then another man waiting on the queue for picking up post letters. Heard our conversation and advised me to ask my parents about the letter number. I went out of the post office tried to call my father and ask him about that info. My mother picked up the phone and told me with a bad tone my father has went to my village and was on her way to scream to me over the phone and blame me for the fact that the letter was missing the post box on the letter head. I got really mad and had a desire to break the phone in the ground so I closed the line. Then we went to Sali and left the bike. I felt really fucked up and desperate the devil tried to suggest me some ideas about a suicide again as well as some ideas abotu smoking. So I started praying, while listening Larry Norman on my mp3 player. I went to the dorm still in desperation, I passed the pigeon holes, anyways I thought OK let me check my pigeon hole. And guesss what HalleluYah! The registration form for the letter my parents sent me week ago was there! Glory be to Our Father through Our Saviour Jesus and the Holy Spirit! Glory be to the God Almighty! For obviously he heard my prayers from Sunday and Saturday and responded. The whole story had a moral for me from God. If we try to do things our way without the Lord we might do nothing, as our Lord and saviour Jesus Christ said “Without me you cannot do nothing!”. However again I tried to act in the newly created situation the human way I thought nevertheless the fact thatonly 10 minutes were left until the closure of the presikhaf’s post office. I ran up to the post office with the letter acceptance form and asked for my letter and guess what the lady on the reception told me that I had to come again after 10:00 the next morning because the letter haven’t arrived yet. The moral that God gave me is it’s all in his hands even in the situation where we thing he is not in control, he is and things does happen not in the time we want but in the time he decided!END—–