1 | Linux System Administration |
---|
2 | |
---|
3 | Apache SSL Certificate Generation and Use |
---|
4 | |
---|
5 | 1. Create a local SSL Certificate repository |
---|
6 | -------------------------------------------- |
---|
7 | |
---|
8 | Log in to your machine either as the root user, or once logged in become the root |
---|
9 | user, then do: |
---|
10 | |
---|
11 | # mkdir /etc/ssl/localcerts |
---|
12 | |
---|
13 | |
---|
14 | 2. Generate a locally signed Digital Certficate for Apache |
---|
15 | ---------------------------------------------------------- |
---|
16 | |
---|
17 | We'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) |
---|
19 | to allow Apache to start without prompting for a passphrase. |
---|
20 | |
---|
21 | Create our own self signed certificate: |
---|
22 | |
---|
23 | # cd /etc/ssl/localcerts |
---|
24 | # mkdir apache |
---|
25 | # cd apache |
---|
26 | |
---|
27 | Ubuntu uses a special wrapper program to create a self-signed certificate. You can |
---|
28 | create your own, manually generated certificates, but this method works fine for what |
---|
29 | we 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 | |
---|
33 | When you are prompted to enter the host name to use in the SSL certificate enter: |
---|
34 | |
---|
35 | extx.ws.nsrc.org |
---|
36 | |
---|
37 | and tab to "<OK>" and press ENTER to continue. |
---|
38 | |
---|
39 | Now you have a local certificate named server.pem in the directory /etc/ssl/localcerts/apache. |
---|
40 | |
---|
41 | |
---|
42 | 3. Enable Apache SSL configuration for your default domain |
---|
43 | ---------------------------------------------------------- |
---|
44 | |
---|
45 | We need to update the /etc/apache2/sites-available/default-ssl configuration file and enable |
---|
46 | the site for our server. First we edit the file: |
---|
47 | |
---|
48 | # cd /etc/apache2/sites-available |
---|
49 | # vi default-ssl.conf |
---|
50 | |
---|
51 | |
---|
52 | Find the line that says: |
---|
53 | |
---|
54 | SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem |
---|
55 | |
---|
56 | Comment it out, it will look like: |
---|
57 | |
---|
58 | #SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem |
---|
59 | |
---|
60 | And create a line just below that says: |
---|
61 | |
---|
62 | SSLCertificateFile /etc/ssl/localcerts/apache/server.pem |
---|
63 | |
---|
64 | Now 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 | |
---|
70 | To verify that Apache will provide an encrypted connection to pcX.ws.nsrc.org open a web browser |
---|
71 | and go to: |
---|
72 | |
---|
73 | https://extX.ws.nsrc.org/ |
---|
74 | |
---|
75 | You should receive a warning that the certificate is not trusted. Click "Continue" (this is different |
---|
76 | in each web browser) to view your home page. |
---|
77 | |
---|
78 | 4. Manually verify SSL certificate use on your web server |
---|
79 | --------------------------------------------------------- |
---|
80 | |
---|
81 | You can use the built-in OpenSSL command line tool to connect to your web server and see information about |
---|
82 | the 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 | |
---|
86 | And you will see information about the SSL Digital Certificate for the site pcX.ws.nsrc.org. You should see |
---|
87 | something like: |
---|
88 | |
---|
89 | subject=/CN=extX.ws.nsrc.org |
---|
90 | issuer=/CN=extX.ws.nsrc.org |
---|
91 | --- |
---|
92 | No client certificate CA names sent |
---|
93 | --- |
---|
94 | SSL handshake has read 1004 bytes and written 319 bytes |
---|
95 | --- |
---|
96 | New, TLSv1/SSLv3, Cipher is DHE-RSA-AES256-SHA |
---|
97 | Server public key is 1024 bit |
---|
98 | Secure Renegotiation IS supported |
---|
99 | Compression: NONE |
---|
100 | Expansion: NONE |
---|
101 | SSL-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 | --- |
---|
112 | closed |
---|
113 | |
---|
114 | |
---|
115 | Press CTRL-C to exit from the program. |
---|
116 | |
---|
117 | As you can see reasonable ciphers are available to ensure encrypted communication between the server and |
---|
118 | a client connecting via https (SSL). |
---|