Cryptography Tutorials - Herong's Tutorial Examples - v5.42, by Herong Yang
"OpenSSL" Generating Certificates in DER and PEM
This section provides a tutorial example on how to generate certificates in DER and PEM formats using 'OpenSSL'.
After tested how "keytool" can be used to export certificates in DER and PEM formats, I decided to try with "OpenSSL" to see if it can generate certificates in DER and PEM formats or not. What I did was to:
The test session was recorded below:
herong> openssl genrsa -out herong.key -des 1024 Loading 'screen' into random state - done Generating RSA private key, 1024 bit long modulus .........................++++++ ...................++++++ e is 65537 (0x10001) Enter pass phrase for herong.key: keypass Verifying - Enter pass phrase for herong.key: keypass herong> openssl req -new -x509 -key herong.key -out openssl_crt.pem \ -outform pem -config openssl.cnf Enter pass phrase for herong.key: keypass 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) [CA]: State or Province Name (full name) [HY State]: Locality Name (eg, city) [HY City]: Organization Name (eg, company) [HY Company]: Organizational Unit Name (eg, section) [HY Unit]: Common Name (eg, YOUR name) [Herong Yang]: Email Address [herongyang.com]: herong> openssl x509 -in openssl_crt.pem -inform pem \ -out openssl_crt.der -outform der
Now I got one certificate generated by "OpenSSL" and stored in two files: openssl_crt.der and openssl_crt.pem. How can I verify that they are really using DER and PEM formats? I used "keytool" to try to view them as described in the next section.
Table of Contents
Introduction to AES (Advanced Encryption Standard)
DES Algorithm - Illustrated with Java Programs
DES Algorithm Java Implementation
DES Algorithm - Java Implementation in JDK JCE
DES Encryption Operation Modes
PHP Implementation of DES - mcrypt
Blowfish - 8-Byte Block Cipher
Secret Key Generation and Management
Cipher - Secret Key Encryption and Decryption
RSA Implementation using java.math.BigInteger Class
Introduction of DSA (Digital Signature Algorithm)
Java Default Implementation of DSA
Private key and Public Key Pair Generation
PKCS#8/X.509 Private/Public Encoding Standards
Cipher - Public Key Encryption and Decryption
OpenSSL Introduction and Installation
OpenSSL Generating and Managing RSA Keys
OpenSSL Generating and Signing CSR
OpenSSL Validating Certificate Path
"keytool" and "keystore" from JDK
"OpenSSL" Signing CSR Generated by "keytool"
Migrating Keys from "keystore" to "OpenSSL" Key Files
►Certificate X.509 Standard and DER/PEM Formats
What Is DER (Distinguished Encoding Rules) Encoding?
What Is PEM (Privacy Enhanced Mail) Encoding?
"keytool" Exporting Certificates in DER and PEM
"OpenSSL" Viewing Certificates in DER and PEM
►"OpenSSL" Generating Certificates in DER and PEM
"keytool" Viewing Certificates in DER and PEM
"keytool" Importing Certificates in DER and PEM
Migrating Keys from "OpenSSL" Key Files to "keystore"