Debian Tutorials

Debian Tutorials


Step by step tutorials showing you how to install and configure various applications and services on Debian based Linux distros.

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories


Create your private certificate authority (CA)

adminadmin

Creating a private CA can be useful if you have a lot of services encrypting data for internal use but don’t need the domain to be verified by a public CA like Verisign, Thawte etc. By importing the CA to all computers that will use these services users won’t get the a popup in IE and Firefox saying that the certificate is invalid.

1. Create a CA certificate

Create a private key for your CA:

openssl genrsa -des3 -out ca.key 4096

You will need to enter passphrase, this password will be used everytime you sign a certificate with this CA

Make sure unauthorized users don’t get access to your private key:

chmod 700 ca.key

Create the certificate, this will be shown as the top level certificate when you have signed other certificates so choose expiration day and the certificate contents carefully. All signed certificates will expirate if the top level certificate expires so you may want to choose a few years here

openssl req -new -x509 -days 3650 -key ca.key -out ca.crt

Here is a sample of input values:

Enter pass phrase for ca.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) [AU]:US
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Debian Tutorials
Organizational Unit Name (eg, section) []:
Common Name (eg, YOUR name) []:Debian Tutorials CA
Email Address []:

Common name will be shown when users are displaying details about the certificate

2. Create a certificate request

Create a private key:

openssl genrsa -des3 -out secure.debiantutorials.net.key 4096

Replace secure.debiantutorials.net by your domain name

Create the certificate request

openssl req -new -key secure.debiantutorials.net.key -out secure.debiantutorials.net.csr

Make sure you put your domain name in the “Common Name” field

3. Sign the certificate with your CA certificate

You will need to provide the certificate request here and the CA key

openssl x509 -req -days 365 -in secure.debiantutorials.net.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out secure.debiantutorials.net.crt

4. Remove password from key (optional)

If using the certificate with Apache, Postfix or other services you may need to replace the password in your private key so that the service can start without user interaction

openssl rsa -in secure.debiantutorials.net.key -out secure.debiantutorials.net.key.insecure
mv secure.debiantutorials.net.key secure.debiantutorials.net.key.secure
mv secure.debiantutorials.net.key.insecure secure.debiantutorials.net.key

Set permissions on the keys

chmod 700 secure.debiantutorials.net.key
chmod 700 secure.debiantutorials.net.key.secure

Comments 3
  • ciaran
    Posted on

    ciaran ciaran

    Author

    good stuff, thanks !!!


  • Gerald Schneider
    Posted on

    Gerald Schneider Gerald Schneider

    Author

    Thanks for this straight forward guide. Just a side node, chmod 600 is sufficient, no need to make the keys executable.


  • Vasil
    Posted on

    Vasil Vasil

    Author

    Can you help me?
    I have two websites on my local machine. When I do all this steps its work only for firs site (i made one CA and two requests for every site). For second site I have error – ssl_error_bad_cert_domain. Can someone help me?