Agenda: apache-ssl-exercises.txt

File apache-ssl-exercises.txt, 3.7 KB (added by pmatsiko, 6 years ago)
Line 
1Linux System Administration
2
3Apache SSL Certificate Generation and Use
4
51. Create a local SSL Certificate repository
6--------------------------------------------
7
8Log in to your machine either as the root user, or once logged in become the root
9user, then do:
10
11        # mkdir /etc/ssl/localcerts
12
13
142. Generate a locally signed Digital Certficate for Apache
15----------------------------------------------------------
16
17We'll use openssl to generate a local server key, local server certificate, a CSR
18(Certificate Signing Request) and a server key that is unencrypted (no passphrase)
19to allow Apache to start without prompting for a passphrase.
20
21Create our own self signed certificate:
22
23        # cd /etc/ssl/localcerts
24        # mkdir apache
25        # cd apache
26
27Ubuntu uses a special wrapper program to create a self-signed certificate. You can
28create your own, manually generated certificates, but this method works fine for what
29we are doing. To generate your local certificate for apache do:
30
31        # make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/ssl/localcerts/apache/server.pem
32
33When you are prompted to enter the host name to use in the SSL certificate enter:
34
35        extx.ws.nsrc.org
36
37and tab to "<OK>" and press ENTER to continue.
38
39Now you have a local certificate named server.pem in the directory /etc/ssl/localcerts/apache.
40
41
423. Enable Apache SSL configuration for your default domain
43----------------------------------------------------------
44
45We need to update the /etc/apache2/sites-available/default-ssl configuration file and enable
46the site for our server. First we edit the file:
47
48        # cd /etc/apache2/sites-available
49        # vi default-ssl.conf
50
51
52Find the line that says:
53
54        SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem
55
56Comment it out, it will look like:
57
58        #SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem
59
60And create a line just below that says:
61
62        SSLCertificateFile    /etc/ssl/localcerts/apache/server.pem
63
64Now save the file and exit, then we'll enable the Apache SSL configuration and the SSL module .
65
66        # a2ensite default-ssl
67        # a2enmod ssl
68        # service apache2 restart
69
70To verify that Apache will provide an encrypted connection to pcX.ws.nsrc.org open a web browser
71and go to:
72
73        https://extX.ws.nsrc.org/
74
75You should receive a warning that the certificate is not trusted. Click "Continue" (this is different
76in each web browser) to view your home page.
77
784. Manually verify SSL certificate use on your web server
79---------------------------------------------------------
80
81You can use the built-in OpenSSL command line tool to connect to your web server and see information about
82the SSL certificate in use. To do this do (as root or a regular user):
83
84        # openssl s_client -connect extX.ws.nsrc.org:443
85
86And you will see information about the SSL Digital Certificate for the site pcX.ws.nsrc.org. You should see
87something like:
88
89subject=/CN=extX.ws.nsrc.org
90issuer=/CN=extX.ws.nsrc.org
91---
92No client certificate CA names sent
93---
94SSL handshake has read 1004 bytes and written 319 bytes
95---
96New, TLSv1/SSLv3, Cipher is DHE-RSA-AES256-SHA
97Server public key is 1024 bit
98Secure Renegotiation IS supported
99Compression: NONE
100Expansion: NONE
101SSL-Session:
102    Protocol  : TLSv1
103    Cipher    : DHE-RSA-AES256-SHA
104    Session-ID: 18541F63DDD15E050A3C72ED9415CC9A00B7DCD0DC472919AE4E4B67E4D88837
105    Session-ID-ctx:
106    Master-Key: 20BC655CCF5BC3D3BECD1D04333F928CB1A756871E5ACBD94455DD324E7E62BE29D11664AFDD61257DB71CBE1B4A7FEE
107    Key-Arg   : None
108    Start Time: 1334826634
109    Timeout   : 300 (sec)
110    Verify return code: 18 (self signed certificate)
111---
112closed
113
114
115Press CTRL-C to exit from the program.
116
117As you can see reasonable ciphers are available to ensure encrypted communication between the server and
118a client connecting via https (SSL).