Wednesday, August 02, 2006

SSL, How can we generate CSR and CRT

# openssl genrsa -des3 -out domainname.key 1024
Generating RSA private key, 1024 bit long modulus
............++++++
................++++++
e is 65537 (0x10001)
Enter pass phrase for domainname.key:
Verifying - Enter pass phrase for domainname.key:

openssl req -new -key domainname.key -out domainname.csr
Enter pass phrase for domainname.key:
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) [GB]:TH
State or Province Name (full name) [Berkshire]:Bangkok
Locality Name (eg, city) [Newbury]:Test
Organization Name (eg, company) [My Company Ltd]:Test
Organizational Unit Name (eg, section) []:TEST
Common Name (eg, your name or your server's hostname) []:www.test.com
Email Address []:test@hotmail.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:



You'll have CSR file and if you want CRT file, you can

# openssl x509 -req -days 36500 -in domainname.csr -signkey domainname.key -out domainname.crt
Signature ok
subject=/C=TH/ST=Bangkok/L=Test/O=Test/OU=TEST/CN=www.test.com/emailAddress=test@hotmail.com
Getting Private key
Enter pass phrase for domainname.key: