Agenda: apache-ssl-exercises.2.txt

File apache-ssl-exercises.2.txt, 3.8 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 lines that say:
53
54        SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem
55        SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
56
57Comment them out, and they will look like:
58
59        #SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem
60        #SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
61
62And create a line just below that says:
63
64        SSLCertificateFile    /etc/ssl/localcerts/apache/server.pem
65
66Now save the file and exit, then we'll enable the Apache SSL configuration and the SSL module .
67
68        # a2ensite default-ssl
69        # a2enmod ssl
70        # service apache2 restart
71
72To verify that Apache will provide an encrypted connection to extX.ws.nsrc.org open a web browser
73and go to:
74
75        https://extX.ws.nsrc.org/
76
77You should receive a warning that the certificate is not trusted. Click "Continue" (this is different
78in each web browser) to view your home page.
79
804. Manually verify SSL certificate use on your web server
81---------------------------------------------------------
82
83You can use the built-in OpenSSL command line tool to connect to your web server and see information about
84the SSL certificate in use. To do this do (as root or a regular user):
85
86        # openssl s_client -connect extX.ws.nsrc.org:443
87
88And you will see information about the SSL Digital Certificate for the site pcX.ws.nsrc.org. You should see
89something like:
90
91subject=/CN=extX.ws.nsrc.org
92issuer=/CN=extX.ws.nsrc.org
93---
94No client certificate CA names sent
95---
96SSL handshake has read 1004 bytes and written 319 bytes
97---
98New, TLSv1/SSLv3, Cipher is DHE-RSA-AES256-SHA
99Server public key is 1024 bit
100Secure Renegotiation IS supported
101Compression: NONE
102Expansion: NONE
103SSL-Session:
104    Protocol  : TLSv1
105    Cipher    : DHE-RSA-AES256-SHA
106    Session-ID: 18541F63DDD15E050A3C72ED9415CC9A00B7DCD0DC472919AE4E4B67E4D88837
107    Session-ID-ctx:
108    Master-Key: 20BC655CCF5BC3D3BECD1D04333F928CB1A756871E5ACBD94455DD324E7E62BE29D11664AFDD61257DB71CBE1B4A7FEE
109    Key-Arg   : None
110    Start Time: 1334826634
111    Timeout   : 300 (sec)
112    Verify return code: 18 (self signed certificate)
113---
114closed
115
116
117Press CTRL-C to exit from the program.
118
119As you can see reasonable ciphers are available to ensure encrypted communication between the server and
120a client connecting via https (SSL).