Difference between revisions of "Be your own CA"

From BubbaWiki
Jump to navigation Jump to search
(Created page with '= Be your own Certificate Authority<br> = This how-to describes to create your own CA certificate and sign your own certificates.<br> Create the CA Certificate and Key su -<br...')
 
Line 1: Line 1:
= Be your own Certificate Authority<br> =
= Be your own Certificate Authority<br> =


This how-to describes to create your own CA certificate and sign your own certificates.<br>
This how-to describes to create your own CA certificate and sign your own certificates.<br>  


Create the CA Certificate and Key
<br>


su -<br>mkdir -m 0755 \<br> CA \<br> CA/private \<br> CA/certs \<br> CA/newcerts \<br> CA/crl<br>cd CA<br>cp /etc/ssl/openssl.cnf .<br>chmod 600 index.txt serial openssl.cnf
== Create the CA Certificate and Key  ==


Aanpassing in openssl.cnf<br>default_md = sha256<br>default_bits = 2048<br>dir = . # Where everything is kept<br>certificate = $dir/certs/myca.crt # The CA certificate<br>private_key = $dir/private/myca.key # The private key
Become the root user<br>
<pre>su -
mkdir -m 0755 CA CA/private CA/certs CA/newcerts CA/crl
cd CA
cp /etc/ssl/openssl.cnf .
chmod 600 index.txt serial openssl.cnf </pre>
Modify the following parameters in the just copied file openssl.cnf<br>
<pre>default_md = sha256
default_bits = 2048
dir = . # Where everything is kept
certificate = $dir/certs/myca.crt # The CA certificate
private_key = $dir/private/myca.key # The private key</pre>
Create your CA certificate<br>
<pre>openssl req -config openssl.cnf -new -x509 -extensions v3_ca -keyout private/myca.key -out certs/myca.crt -days 1825</pre>
Keep your password and key safe!<br>
<pre>chmod 400 private/myca.key </pre>
== Generate a Certificate Request  ==


<br>openssl req -config openssl.cnf -new -x509 -extensions v3_ca -keyout private/myca.key -out certs/myca.crt -days 1825
Create your B3 server certificate. <br>


chmod 400 private/myca.key
Fill in your B3 server name when asked the question: Common Name (eg, YOUR name) []:<br>
<pre>openssl req -config openssl.cnf -new -nodes -keyout private/server.key -out server.csr -days 365</pre>
Keep the key safe<br>
<pre>chmod 400 private/server.key</pre>
== Sign the Certificate Request  ==
<pre>openssl ca -config openssl.cnf -policy policy_anything -out certs/server.crt -infiles server.csr
rm server.csr</pre>
== Verify the certificate  ==
<pre>openssl x509 -subject -issuer -enddate -noout -in certs/server.crt
openssl verify -purpose sslserver -CAfile certs/myca.crt certs/server.crt</pre>
== Bounce Apache  ==


Generate a Certificate Request
Replace the old certifcates with your new certificates<br>
<pre>cp /etc/apache2/cacert.pem /etc/apache2/cacert.pem.orig
cp /etc/apache2/privkey.pem /etc/apache2/privkey.pem.orig


openssl req -config openssl.cnf -new -nodes -keyout private/server.key -out server.csr -days 365
cp /root/CA/certs/server.crt /etc/apache2/cacert.pem
cp /root/CA/private/server.key /etc/apache2/privkey.pem</pre>
Restart the Apache webserver<br>
<pre>/etc/init.d/apache2 restart</pre>
== Importeer CA in browser  ==


Fill in server name at Common Name (eg, YOUR name) []:www.onsleven.com
Import the CA certificate, this is file /root/CA/certs/myca.crt, into the browser of your choice.  


<br>chmod 400 private/server.key
== References  ==


Sign the Certificate Request
*http://openssl.org/
 
*http://www.g-loaded.eu/2005/11/10/be-your-own-ca/
openssl ca -config openssl.cnf -policy policy_anything -out certs/server.crt -infiles server.csr
*http://www.eclectica.ca/howto/ssl-cert-howto.php<br>
 
*http://www.top20toolbar.com/misc/codesigncert.htm<br>
rm server.csr
 
Verify the certificate
 
openssl x509 -subject -issuer -enddate -noout -in certs/server.crt<br>openssl verify -purpose sslserver -CAfile certs/myca.crt certs/server.crt
 
Apache herstarten
 
cp /etc/apache2/cacert.pem /etc/apache2/cacert.pem.orig<br>cp /etc/apache2/privkey.pem /etc/apache2/privkey.pem.orig
 
cp /root/CA/certs/server.crt /etc/apache2/cacert.pem<br>cp /root/CA/private/server.key /etc/apache2/privkey.pem
 
/etc/init.d/apache2 restart
 
Importeer CA in browser
 
take /root/CA/certs/myca.crt and import it into your browser.
 
References
 
http://www.g-loaded.eu/2005/11/10/be-your-own-ca/<br>http://www.eclectica.ca/howto/ssl-cert-howto.php<br>

Revision as of 06:42, 17 August 2011

Be your own Certificate Authority

This how-to describes to create your own CA certificate and sign your own certificates.


Create the CA Certificate and Key

Become the root user

su -
mkdir -m 0755 CA CA/private CA/certs CA/newcerts CA/crl
cd CA
cp /etc/ssl/openssl.cnf .
chmod 600 index.txt serial openssl.cnf 

Modify the following parameters in the just copied file openssl.cnf

default_md = sha256
default_bits = 2048
dir = . # Where everything is kept
certificate = $dir/certs/myca.crt # The CA certificate
private_key = $dir/private/myca.key # The private key

Create your CA certificate

openssl req -config openssl.cnf -new -x509 -extensions v3_ca -keyout private/myca.key -out certs/myca.crt -days 1825

Keep your password and key safe!

chmod 400 private/myca.key 

Generate a Certificate Request

Create your B3 server certificate.

Fill in your B3 server name when asked the question: Common Name (eg, YOUR name) []:

openssl req -config openssl.cnf -new -nodes -keyout private/server.key -out server.csr -days 365

Keep the key safe

chmod 400 private/server.key

Sign the Certificate Request

openssl ca -config openssl.cnf -policy policy_anything -out certs/server.crt -infiles server.csr
rm server.csr

Verify the certificate

openssl x509 -subject -issuer -enddate -noout -in certs/server.crt
openssl verify -purpose sslserver -CAfile certs/myca.crt certs/server.crt

Bounce Apache

Replace the old certifcates with your new certificates

cp /etc/apache2/cacert.pem /etc/apache2/cacert.pem.orig
cp /etc/apache2/privkey.pem /etc/apache2/privkey.pem.orig

cp /root/CA/certs/server.crt /etc/apache2/cacert.pem
cp /root/CA/private/server.key /etc/apache2/privkey.pem

Restart the Apache webserver

/etc/init.d/apache2 restart

Importeer CA in browser

Import the CA certificate, this is file /root/CA/certs/myca.crt, into the browser of your choice.

References