Cryptography Tutorials - Herong's Tutorial Examples - v5.42, by Herong Yang
"keytool -exportcert" Exporting PrivateKeyEntry
This section provides a tutorial example on how to export a 'PrivateKeyEntry' stored in a 'keystore' file using the 'keytool -exportcert' command.
After generating my key pair with the "keytool -genkeypair" command, I got a PrivateKeyEntry inside the keystore file, herong.jks. So I tried to export it using the "keytool -exportcert" command as shown in the following command session:
herong> keytool -exportcert -alias herong_key -keypass keypass \ -keystore herong.jks -storepass jkspass -file herong.crt -rfc Certificate stored in file <herong.crt> herong> more herong.crt -----BEGIN CERTIFICATE----- MIIDODCCAvagAwIBAgIERqplETALBgcqhkjOOAQDBQAwfzELMAkGA1UE... ... Cgfs2kXj/IQCFDC5GT5IrLTIFxAyPUo1tJo2DPkK -----END CERTIFICATE-----
Cool. A certificate was exported. I am not going to explain all the command options used above, because they were explained in previous chapters. But I want to mention this "-rfc" option:
Without "-rfc" option, "keytool" will output certificate in a binary form, which will be very hard to transfer.
I got this certificate exported from the PrivateKeyEntry of my key pair. What is in this certificate? I will try to use "keytool -printcert" command to look into this certificate 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
No "keytool" Command to Export Keys
"keytool -genkeypair" Generating PrivateKeyEntry
►"keytool -exportcert" Exporting PrivateKeyEntry
"keytool -printcert" Printing Certificate Details
"openssl x509" Viewing Certificate Details
"DumpKey.java" Dumping Private Keys Out of "keystore"
"openssl enc" Converting Keys from Binary to PEM
"openssl dsa" Viewing Private and Public Key Pair
Certificate X.509 Standard and DER/PEM Formats
Migrating Keys from "OpenSSL" Key Files to "keystore"