Wednesday, April 22, 2020

Generating a PKCS12 (.p12) Self-Signed Certificate Using OpenSSL on Ubuntu

nagaraju@nagaraju:~$ openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 365 -out certificate.pem
Can't load /home/nagaraju/.rnd into RNG
140366584201664:error:2406F079:random number generator:RAND_load_file:Cannot open file:../crypto/rand/randfile.c:88:Filename=/home/nagaraju/.rnd
Generating a RSA private key
..................................................................+++++
................+++++
writing new private key to 'key.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:91
State or Province Name (full name) [Some-State]:Karnataka
Locality Name (eg, city) []:Bengalore
Organization Name (eg, company) [Internet Widgits Pty Ltd]:TheprogrammersBook
Organizational Unit Name (eg, section) []:IT
Common Name (e.g. server FQDN or YOUR name) []:Nagaraju Gajula
Email Address []:nagaraju@gmail.com
nagaraju@nagaraju:~$ ls
certificate.pem   FromDrive          Pictures               Templates
Desktop           key.pem            Public                 Videos
nagaraju@nagaraju:~$ openssl pkcs12 -inkey key.pem -in certificate.pem -export -out certificate.p12
Enter Export Password:
Verifying - Enter Export Password:
nagaraju@nagaraju:~$ ls
certificate.p12  examples.desktop   Personals              Technology
certificate.pem  FromDrive          Pictures               Templates
Desktop          key.pem            Public                 Videos
nagaraju@nagaraju:~$ 
nagaraju@nagaraju:~$ openssl x509 -text -noout -in certificate.pem
nagaraju@nagaraju:~$ openssl pkcs12 -in certificate.p12 -noout -info

No comments:

Post a Comment

Recent Post

Databricks Delta table merge Example

here's some sample code that demonstrates a merge operation on a Delta table using PySpark:   from pyspark.sql import SparkSession # cre...