Generate Self Sign SSL certificate
- Tools
- Generate Your Apache Self Signed Certificate
- Add in apache configuration
- Install the certificate
Tools
OpenSSL need to be installed. The OpenSSL project does not distribute any code in binary form, and does not officially recommend any specific binary distributions. An informal list of third party products can be found on the wiki.
For linux base, use the repository for the respective distros. For windows, grap the Windows version of OpenSSL
For Centos/RedHat:
Generate Your Apache Self Signed Certificate
For Centos/RedHat:
- req - PKCS#10 certificate request and certificate generating utility.
- -nodes - if this option is specified then if a private key is created it will not be encrypted.
- -x509 - this option outputs a self signed certificate instead of a certificate request. This is typically used to generate a test certificate or a self signed root CA.
- -sha256 - Hasing algorithm used.
- -days - when the -x509 option is being used this specifies the number of days to certify the certificate for. The default is 30 days.
- -newkey - this option creates a new certificate request and a new private key. The argument takes one of several forms. rsa:nbits, where nbits is the number of bits, generates an RSA key nbits in size.
- -keyout - this gives the filename to write the newly created private key to.
- -out - This specifies the output filename to write to or standard output by default.
You will be prompted to enter your organizational information and a common name. The common name should be the fully qualified domain name for the site you are securing (www.server.com). You can leave the email address, challenge password, and optional company name blank. When the command is finished running, it will create two files: a privateKey.key file and a certificate.crt self signed certificate file valid for 365 days.
use *.ningzeta.com in common name for generating wildcard certificate
If you want to combine the key and the certificate in a pem file
Add in apache configuration
Edit and add the following the httpd.conf
Restart the apache service daemon.
Install the certificate
On Microsoft Windows
- Open Microsoft Management Console (Start –> Run –> mmc.exe);
- Choose File –> Add/Remove Snap-in;
- In the Standalone tab, choose Add;
- Choose the Certificates snap-in, and click Add;
- In the wizard, choose the Computer Account, and then choose Local Computer. Press Finish to end the wizard;
- Close the Add/Remove Snap-in dialog;
- Navigate to Certificates (Local Computer)
- Choose a store to import:
- If you have the Root CA certificate for the company that issued the certificate, choose Trusted Root Certification Authorities;
- If you have the certificate for the server itself, choose Other People
- Right-click the store and choose All Tasks –> Import
- Follow the wizard and provide the certificate file you have;
On a Linux distribution
- Place the certificate in the machine. The following commands will assume that it is located in /root/certificate.cer
- As root run:
You will probably be asked for a password. If you haven’t changed it, the password is “changeit”. When the tool asks you if you want to trust this certificate, answer “yes”.
Refer OpenSSL and here for more info.