Generating Private Keys
This section provides a tutorial example on how to use the 'keytool -genkey' command to generate a pair of private key and public key. This command also generates a self-signed certificate from the key pair.
The "keytool -genkey" command can be used to generate a pair of private key and public key.
It can also be used to generate a self-signed certificate from the key pair.
In the first example, I want to try the "-genkey" command option:
C:herong>keytool -genkey -alias my_home -keystore herong.jks
Enter keystore password: HerongJKS
What is your first and last name?
[Unknown]: Herong Yang
What is the name of your organizational unit?
[Unknown]: My Unit
What is the name of your organization?
[Unknown]: My Home
What is the name of your City or Locality?
[Unknown]: My City
What is the name of your State or Province?
[Unknown]: My State
What is the two-letter country code for this unit?
Is <CN=Herong Yang, OU=My Unit, O=My Home, L=My City, ST=My State,
Enter key password for <my_home>
(RETURN if same as keystore password): My1stKey
Based on the documentation, the above example command did the following for me:
- Create a "keystore" file, herong.jks, in JKS format, with a password of "HerongJKS".
- Generate a pair of private key and public key for me using the default implementation
of the default security package.
- Generate a certificate chain with a single self-signed certificate of my public key.
- Insert a key entry into the keystore with my private key and the certificate chain.
- The key entry is protected by a password of "My1stKey".
The following command shows that we do have a key entry in the keystore file:
C:herong>keytool -list -keystore herong.jks -storepass HerongJKS
Keystore type: jks
Keystore provider: SUN
Your keystore contains 1 entry:
my_home, Sat Jun 1 07:15:16 EDT 2002, keyEntry,
Table of Contents
About This Book
Cryptography Basic Concepts
Introduction to AES (Advanced Encryption Standard)
Introduction to DES Algorithm
DES Algorithm - Illustrated with Java Programs
DES Algorithm Java Implementation
DES Algorithm - Java Implementation in JDK JCE
DES Encryption Operation Modes
DES in Stream Cipher Modes
PHP Implementation of DES - mcrypt
Blowfish - 8-Byte Block Cipher
Secret Key Generation and Management
Cipher - Secret Key Encryption and Decryption
Introduction of RSA Algorithm
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
MD5 Mesasge Digest Algorithm
SHA1 Mesasge Digest Algorithm
OpenSSL Introduction and Installation
OpenSSL Generating and Managing RSA Keys
OpenSSL Managing Certificates
OpenSSL Generating and Signing CSR
OpenSSL Validating Certificate Path
►"keytool" and "keystore" from JDK
Certificates and Certificate Chains
What Is "keystore"?
"keytool" - Command Line Tool
►Generating Private Keys
Exporting and Import Certificates
Generating CSR (Certificate Signing Request)
Cloning Certificates with New Identities
"OpenSSL" Signing CSR Generated by "keytool"
Migrating Keys from "keystore" to "OpenSSL" Key Files
Certificate X.509 Standard and DER/PEM Formats
Migrating Keys from "OpenSSL" Key Files to "keystore"
Using Certificates in IE
Using Certificates in Google Chrome
Using Certificates in Firefox
Full Version in PDF/EPUB