1 <?xml version='1.0' encoding='UTF-8' ?>
2 <!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
7 Licensed to the Apache Software Foundation (ASF) under one or more
8 contributor license agreements. See the NOTICE file distributed with
9 this work for additional information regarding copyright ownership.
10 The ASF licenses this file to You under the Apache License, Version 2.0
11 (the "License"); you may not use this file except in compliance with
12 the License. You may obtain a copy of the License at
14 http://www.apache.org/licenses/LICENSE-2.0
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
23 <manualpage metafile="ssl_howto.xml.meta">
24 <parentdocument href="./">SSL/TLS</parentdocument>
26 <title>SSL/TLS Strong Encryption: How-To</title>
30 <p>This documented is intended to get you started, and get a few things
31 working. You are strongly encouraged to read the rest of the SSL
32 documentation, and arrive at a deeper understanding of the material,
33 before progressing to the advanced techniques.</p>
36 <section id="configexample">
37 <title>Basic Configuration Example</title>
39 <p>Your SSL configuration will need to contain, at minimum, the
40 following directives.</p>
42 <highlight language="config">
44 <VirtualHost *:443>
45 ServerName www.example.com
47 SSLCertificateFile /path/to/www.example.com.cert
48 SSLCertificateKeyFile /path/to/www.example.com.key
54 <section id="ciphersuites">
55 <title>Cipher Suites and Enforcing Strong Security</title>
57 <li><a href="#onlystrong">How can I create an SSL server which accepts strong encryption only?</a></li>
58 <li><a href="#strongurl">How can I create an SSL server which accepts all types of ciphers in general, but
59 requires a strong cipher for access to a particular URL?</a></li>
62 <section id="onlystrong">
63 <title>How can I create an SSL server which accepts strong encryption
65 <p>The following enables only the strongest ciphers:</p>
66 <highlight language="config">
67 SSLCipherSuite HIGH:!aNULL:!MD5
70 <p>While with the following configuration you specify a preference
71 for specific speed-optimized ciphers (which will be selected by
72 mod_ssl, provided that they are supported by the client):</p>
74 <highlight language="config">
75 SSLCipherSuite RC4-SHA:AES128-SHA:HIGH:!aNULL:!MD5
76 SSLHonorCipherOrder on
80 <section id="strongurl">
81 <title>How can I create an SSL server which accepts all types of ciphers
82 in general, but requires a strong ciphers for access to a particular
84 <p>Obviously, a server-wide <directive
85 module="mod_ssl">SSLCipherSuite</directive> which restricts
86 ciphers to the strong variants, isn't the answer here. However,
87 <module>mod_ssl</module> can be reconfigured within <code>Location</code>
88 blocks, to give a per-directory solution, and can automatically force
89 a renegotiation of the SSL parameters to meet the new configuration.
90 This can be done as follows:</p>
91 <highlight language="config">
92 # be liberal in general
93 SSLCipherSuite ALL:!aNULL:RC4+RSA:+HIGH:+MEDIUM:+LOW:+EXP:+eNULL
95 <Location /strong/area>
96 # but https://hostname/strong/area/ and below
97 # requires strong ciphers
98 SSLCipherSuite HIGH:!aNULL:!MD5
103 <!-- /ciphersuites -->
105 <section id="accesscontrol">
106 <title>Client Authentication and Access Control</title>
108 <li><a href="#allclients">How can I force clients to authenticate using certificates?</a></li>
109 <li><a href="#arbitraryclients">How can I force clients to authenticate using certificates for a
110 particular URL, but still allow arbitrary clients to access the rest of the server?</a></li>
111 <li><a href="#certauthenticate">How can I allow only clients who have certificates to access a
112 particular URL, but allow all clients to access the rest of the server?</a></li>
113 <li><a href="#intranet">How can I require HTTPS with strong ciphers, and either
114 basic authentication or client certificates, for access to part of the
115 Intranet website, for clients coming from the Internet?</a></li>
118 <section id="allclients">
119 <title>How can I force clients to authenticate using certificates?</title>
121 <p>When you know all of your users (eg, as is often the case on a corporate
122 Intranet), you can require plain certificate authentication. All you
123 need to do is to create client certificates signed by your own CA
124 certificate (<code>ca.crt</code>) and then verify the clients against this
126 <highlight language="config">
127 # require a client certificate which has to be directly
128 # signed by our CA certificate in ca.crt
129 SSLVerifyClient require
131 SSLCACertificateFile conf/ssl.crt/ca.crt
135 <section id="arbitraryclients">
136 <title>How can I force clients to authenticate using certificates for a
137 particular URL, but still allow arbitrary clients to access the rest of the server?</title>
139 <p>To force clients to authenticate using certificates for a particular URL,
140 you can use the per-directory reconfiguration features of
141 <module>mod_ssl</module>:</p>
143 <highlight language="config">
145 SSLCACertificateFile conf/ssl.crt/ca.crt
147 <Location /secure/area>
148 SSLVerifyClient require
154 <section id="certauthenticate">
155 <title>How can I allow only clients who have certificates to access a
156 particular URL, but allow all clients to access the rest of the server?</title>
158 <p>The key to doing this is checking that part of the client certificate
159 matches what you expect. Usually this means checking all or part of the
160 Distinguished Name (DN), to see if it contains some known string.
161 There are two ways to do this, using either <module>mod_auth_basic</module> or
162 <directive module="mod_ssl">SSLRequire</directive>.</p>
164 <p>The <module>mod_auth_basic</module> method is generally required when
165 the certificates are completely arbitrary, or when their DNs have
166 no common fields (usually the organisation, etc.). In this case,
167 you should establish a password database containing <em>all</em>
168 clients allowed, as follows:</p>
170 <highlight language="config">
172 SSLCACertificateFile conf/ssl.crt/ca.crt
173 SSLCACertificatePath conf/ssl.crt
175 <Directory /usr/local/apache2/htdocs/secure/area>
176 SSLVerifyClient require
178 SSLOptions +FakeBasicAuth
180 AuthName "Snake Oil Authentication"
182 AuthBasicProvider file
183 AuthUserFile /usr/local/apache2/conf/httpd.passwd
188 <p>The password used in this example is the DES encrypted string "password".
189 See the <directive module="mod_ssl">SSLOptions</directive> docs for more
192 <example><title>httpd.passwd</title><pre>
193 /C=DE/L=Munich/O=Snake Oil, Ltd./OU=Staff/CN=Foo:xxj31ZMTZzkVA
194 /C=US/L=S.F./O=Snake Oil, Ltd./OU=CA/CN=Bar:xxj31ZMTZzkVA
195 /C=US/L=L.A./O=Snake Oil, Ltd./OU=Dev/CN=Quux:xxj31ZMTZzkVA</pre>
198 <p>When your clients are all part of a common hierarchy, which is encoded
199 into the DN, you can match them more easily using <directive module="mod_ssl"
200 >SSLRequire</directive>, as follows:</p>
203 <highlight language="config">
205 SSLCACertificateFile conf/ssl.crt/ca.crt
206 SSLCACertificatePath conf/ssl.crt
208 <Directory /usr/local/apache2/htdocs/secure/area>
209 SSLVerifyClient require
211 SSLOptions +FakeBasicAuth
213 SSLRequire %{SSL_CLIENT_S_DN_O} eq "Snake Oil, Ltd." \
214 and %{SSL_CLIENT_S_DN_OU} in {"Staff", "CA", "Dev"}
219 <section id="intranet">
220 <title>How can I require HTTPS with strong ciphers, and either basic
221 authentication or client certificates, for access to part of the
222 Intranet website, for clients coming from the Internet? I still want to allow
223 plain HTTP access for clients on the Intranet.</title>
225 <p>These examples presume that clients on the Intranet have IPs in the range
226 192.168.1.0/24, and that the part of the Intranet website you want to allow
227 internet access to is <code>/usr/local/apache2/htdocs/subarea</code>.
228 This configuration should remain outside of your HTTPS virtual host, so
229 that it applies to both HTTPS and HTTP.</p>
231 <highlight language="config">
232 SSLCACertificateFile conf/ssl.crt/company-ca.crt
234 <Directory /usr/local/apache2/htdocs>
235 # Outside the subarea only Intranet access is granted
236 Require ip 192.168.1.0/24
239 <Directory /usr/local/apache2/htdocs/subarea>
240 # Inside the subarea any Intranet access is allowed
241 # but from the Internet only HTTPS + Strong-Cipher + Password
242 # or the alternative HTTPS + Strong-Cipher + Client-Certificate
244 # If HTTPS is used, make sure a strong cipher is used.
245 # Additionally allow client certs as alternative to basic auth.
246 SSLVerifyClient optional
248 SSLOptions +FakeBasicAuth +StrictRequire
249 SSLRequire %{SSL_CIPHER_USEKEYSIZE} >= 128
251 # Force clients from the Internet to use HTTPS
253 RewriteCond %{REMOTE_ADDR} !^192\.168\.1\.[0-9]+$
254 RewriteCond %{HTTPS} !=on
257 # Allow Network Access and/or Basic Auth
260 # Network Access Control
261 Require ip 192.168.1.0/24
263 # HTTP Basic Authentication
265 AuthName "Protected Intranet Area"
266 AuthBasicProvider file
267 AuthUserFile conf/protected.passwd
273 <!-- /access control -->
275 <section id="logging">
276 <title>Logging</title>
278 <p><module>mod_ssl</module> can log extremely verbose debugging information
279 to the error log, when its <directive module="core">LogLevel</directive> is
280 set to the higher trace levels. On the other hand, on a very busy server,
281 level <code>info</code> may already be too much. Remember that you can
282 configure the <directive module="core">LogLevel</directive> per module to
283 suite your needs.</p>