Saturday, November 6, 2010

How To Generate SSL Key, CSR certificate For Apache.


1. [root@abc:~]# openssl --help
This command is used to see whether OPENSSL is installed /not in the server.

2. First, generate a private key on the Linux server that runs Apache webserver using openssl command as shown below
[root@abc:~]# openssl genrsa -des3 -out domain name.key 1024/2048
Generating RSA private key, 1024/2048 bit long modulus
.......................................++++++
...................................................++++++
e is 73547 (0x01001)
Enter pass phrase for www.thegeekstuff.com.key:
Verifying - Enter pass phrase for doamin name.key:

[root@abc:~]# ls -ltr domaim name.*
-rw-r--r-- 1 root root   963 Jun 13 20:26 domaim name.key
The generated private key looks like the following.
[root@abc:~] cat domain name.key
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,485B3C6371C9916E

ymehJu/RowzrclMcixAyxdbfzQphfUAk9oK9kK2
jadfoiyqthakLKNqw9z1MoaqkPyqeHevUm26no
AJKIETHKJADFS2BGb0n61/Ksk8isp7evLM4+QY
KAQETKjdiahteksMJOjXLq+vf5Ra299fZPON7yr
-----END RSA PRIVATE KEY----- 
3. Generate a Certificate Signing Request (CSR)
Using the key generate above, you should generate a (csr) using openssl,
[root@abc:~]# openssl req -new -key doamin name.key -out domain name.csr
Enter pass phrase for domain name.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]:XX
State or Province Name (full name) [Berkshire]:XYZ
Locality Name (eg, city) [Newbury]:ABC
Organization Name (eg, company) [My Company Ltd]:ABCDEF
Organizational Unit Name (eg, section) []:IT
Common Name (eg, your name or your server's hostname) []: XYZXYZ
Email Address []:

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

[root@abc:~]#  ls -ltr domain name.*
-rw-r--r-- 1 root root   963 Jun 13 20:26 domain name.key
-rw-r--r-- 1 root root   664 Jun 13 20:35 domain name.csr 
4. To verify the contents of CSR use the below command, 
[root@abc:~]# openssl -noout -text -in domain name.csr
These are the steps to generate SSL Key, CSR Certificate For Apache.

No comments:

Post a Comment