1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
4 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5 This file is generated from xml source: DO NOT EDIT
6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
8 <title>SSL/TLS Strong Encryption: How-To - Apache HTTP Server</title>
9 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11 <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" />
12 <script src="../style/scripts/prettify.js" type="text/javascript">
15 <link href="../images/favicon.ico" rel="shortcut icon" /></head>
16 <body id="manual-page"><div id="page-header">
17 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
18 <p class="apache">Apache HTTP Server Version 2.4</p>
19 <img alt="" src="../images/feather.gif" /></div>
20 <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div>
22 <a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.4</a> > <a href="./">SSL/TLS</a></div><div id="page-content"><div id="preamble"><h1>SSL/TLS Strong Encryption: How-To</h1>
24 <p><span>Available Languages: </span><a href="../en/ssl/ssl_howto.html" title="English"> en </a> |
25 <a href="../fr/ssl/ssl_howto.html" hreflang="fr" rel="alternate" title="Français"> fr </a></p>
29 <p>This documented is intended to get you started, and get a few things
30 working. You are strongly encouraged to read the rest of the SSL
31 documentation, and arrive at a deeper understanding of the material,
32 before progressing to the advanced techniques.</p>
34 <div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#configexample">Basic Configuration Example</a></li>
35 <li><img alt="" src="../images/down.gif" /> <a href="#ciphersuites">Cipher Suites and Enforcing Strong Security</a></li>
36 <li><img alt="" src="../images/down.gif" /> <a href="#accesscontrol">Client Authentication and Access Control</a></li>
37 <li><img alt="" src="../images/down.gif" /> <a href="#logging">Logging</a></li>
38 </ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
39 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
41 <h2><a name="configexample" id="configexample">Basic Configuration Example</a></h2>
44 <p>Your SSL configuration will need to contain, at minimum, the
45 following directives.</p>
47 <pre class="prettyprint lang-config">
49 <VirtualHost *:443>
50 ServerName www.example.com
52 SSLCertificateFile /path/to/www.example.com.cert
53 SSLCertificateKeyFile /path/to/www.example.com.key
58 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
60 <h2><a name="ciphersuites" id="ciphersuites">Cipher Suites and Enforcing Strong Security</a></h2>
63 <li><a href="#onlystrong">How can I create an SSL server which accepts strong encryption only?</a></li>
64 <li><a href="#strongurl">How can I create an SSL server which accepts all types of ciphers in general, but
65 requires a strong cipher for access to a particular URL?</a></li>
68 <h3><a name="onlystrong" id="onlystrong">How can I create an SSL server which accepts strong encryption
71 <p>The following enables only the strongest ciphers:</p>
72 <pre class="prettyprint lang-config">
73 SSLCipherSuite HIGH:!aNULL:!MD5
77 <p>While with the following configuration you specify a preference
78 for specific speed-optimized ciphers (which will be selected by
79 mod_ssl, provided that they are supported by the client):</p>
81 <pre class="prettyprint lang-config">
82 SSLCipherSuite RC4-SHA:AES128-SHA:HIGH:!aNULL:!MD5
83 SSLHonorCipherOrder on
88 <h3><a name="strongurl" id="strongurl">How can I create an SSL server which accepts all types of ciphers
89 in general, but requires a strong ciphers for access to a particular
92 <p>Obviously, a server-wide <code class="directive"><a href="../mod/mod_ssl.html#sslciphersuite">SSLCipherSuite</a></code> which restricts
93 ciphers to the strong variants, isn't the answer here. However,
94 <code class="module"><a href="../mod/mod_ssl.html">mod_ssl</a></code> can be reconfigured within <code>Location</code>
95 blocks, to give a per-directory solution, and can automatically force
96 a renegotiation of the SSL parameters to meet the new configuration.
97 This can be done as follows:</p>
98 <pre class="prettyprint lang-config">
99 # be liberal in general
100 SSLCipherSuite ALL:!aNULL:RC4+RSA:+HIGH:+MEDIUM:+LOW:+EXP:+eNULL
102 <Location /strong/area>
103 # but https://hostname/strong/area/ and below
104 # requires strong ciphers
105 SSLCipherSuite HIGH:!aNULL:!MD5
110 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
111 <div class="section">
112 <h2><a name="accesscontrol" id="accesscontrol">Client Authentication and Access Control</a></h2>
115 <li><a href="#allclients">How can I force clients to authenticate using certificates?</a></li>
116 <li><a href="#arbitraryclients">How can I force clients to authenticate using certificates for a
117 particular URL, but still allow arbitrary clients to access the rest of the server?</a></li>
118 <li><a href="#certauthenticate">How can I allow only clients who have certificates to access a
119 particular URL, but allow all clients to access the rest of the server?</a></li>
120 <li><a href="#intranet">How can I require HTTPS with strong ciphers, and either
121 basic authentication or client certificates, for access to part of the
122 Intranet website, for clients coming from the Internet?</a></li>
125 <h3><a name="allclients" id="allclients">How can I force clients to authenticate using certificates?</a></h3>
128 <p>When you know all of your users (eg, as is often the case on a corporate
129 Intranet), you can require plain certificate authentication. All you
130 need to do is to create client certificates signed by your own CA
131 certificate (<code>ca.crt</code>) and then verify the clients against this
133 <pre class="prettyprint lang-config">
134 # require a client certificate which has to be directly
135 # signed by our CA certificate in ca.crt
136 SSLVerifyClient require
138 SSLCACertificateFile conf/ssl.crt/ca.crt
143 <h3><a name="arbitraryclients" id="arbitraryclients">How can I force clients to authenticate using certificates for a
144 particular URL, but still allow arbitrary clients to access the rest of the server?</a></h3>
147 <p>To force clients to authenticate using certificates for a particular URL,
148 you can use the per-directory reconfiguration features of
149 <code class="module"><a href="../mod/mod_ssl.html">mod_ssl</a></code>:</p>
151 <pre class="prettyprint lang-config">
153 SSLCACertificateFile conf/ssl.crt/ca.crt
155 <Location /secure/area>
156 SSLVerifyClient require
163 <h3><a name="certauthenticate" id="certauthenticate">How can I allow only clients who have certificates to access a
164 particular URL, but allow all clients to access the rest of the server?</a></h3>
167 <p>The key to doing this is checking that part of the client certificate
168 matches what you expect. Usually this means checking all or part of the
169 Distinguished Name (DN), to see if it contains some known string.
170 There are two ways to do this, using either <code class="module"><a href="../mod/mod_auth_basic.html">mod_auth_basic</a></code> or
171 <code class="directive"><a href="../mod/mod_ssl.html#sslrequire">SSLRequire</a></code>.</p>
173 <p>The <code class="module"><a href="../mod/mod_auth_basic.html">mod_auth_basic</a></code> method is generally required when
174 the certificates are completely arbitrary, or when their DNs have
175 no common fields (usually the organisation, etc.). In this case,
176 you should establish a password database containing <em>all</em>
177 clients allowed, as follows:</p>
179 <pre class="prettyprint lang-config">
181 SSLCACertificateFile conf/ssl.crt/ca.crt
182 SSLCACertificatePath conf/ssl.crt
184 <Directory /usr/local/apache2/htdocs/secure/area>
185 SSLVerifyClient require
187 SSLOptions +FakeBasicAuth
189 AuthName "Snake Oil Authentication"
191 AuthBasicProvider file
192 AuthUserFile /usr/local/apache2/conf/httpd.passwd
198 <p>The password used in this example is the DES encrypted string "password".
199 See the <code class="directive"><a href="../mod/mod_ssl.html#ssloptions">SSLOptions</a></code> docs for more
202 <div class="example"><h3>httpd.passwd</h3><pre>
203 /C=DE/L=Munich/O=Snake Oil, Ltd./OU=Staff/CN=Foo:xxj31ZMTZzkVA
204 /C=US/L=S.F./O=Snake Oil, Ltd./OU=CA/CN=Bar:xxj31ZMTZzkVA
205 /C=US/L=L.A./O=Snake Oil, Ltd./OU=Dev/CN=Quux:xxj31ZMTZzkVA</pre></div>
207 <p>When your clients are all part of a common hierarchy, which is encoded
208 into the DN, you can match them more easily using <code class="directive"><a href="../mod/mod_ssl.html#sslrequire">SSLRequire</a></code>, as follows:</p>
211 <pre class="prettyprint lang-config">
213 SSLCACertificateFile conf/ssl.crt/ca.crt
214 SSLCACertificatePath conf/ssl.crt
216 <Directory /usr/local/apache2/htdocs/secure/area>
217 SSLVerifyClient require
219 SSLOptions +FakeBasicAuth
221 SSLRequire %{SSL_CLIENT_S_DN_O} eq "Snake Oil, Ltd." \
222 and %{SSL_CLIENT_S_DN_OU} in {"Staff", "CA", "Dev"}
228 <h3><a name="intranet" id="intranet">How can I require HTTPS with strong ciphers, and either basic
229 authentication or client certificates, for access to part of the
230 Intranet website, for clients coming from the Internet? I still want to allow
231 plain HTTP access for clients on the Intranet.</a></h3>
234 <p>These examples presume that clients on the Intranet have IPs in the range
235 192.168.1.0/24, and that the part of the Intranet website you want to allow
236 internet access to is <code>/usr/local/apache2/htdocs/subarea</code>.
237 This configuration should remain outside of your HTTPS virtual host, so
238 that it applies to both HTTPS and HTTP.</p>
240 <pre class="prettyprint lang-config">
241 SSLCACertificateFile conf/ssl.crt/company-ca.crt
243 <Directory /usr/local/apache2/htdocs>
244 # Outside the subarea only Intranet access is granted
247 Allow from 192.168.1.0/24
250 <Directory /usr/local/apache2/htdocs/subarea>
251 # Inside the subarea any Intranet access is allowed
252 # but from the Internet only HTTPS + Strong-Cipher + Password
253 # or the alternative HTTPS + Strong-Cipher + Client-Certificate
255 # If HTTPS is used, make sure a strong cipher is used.
256 # Additionally allow client certs as alternative to basic auth.
257 SSLVerifyClient optional
259 SSLOptions +FakeBasicAuth +StrictRequire
260 SSLRequire %{SSL_CIPHER_USEKEYSIZE} >= 128
262 # Force clients from the Internet to use HTTPS
264 RewriteCond %{REMOTE_ADDR} !^192\.168\.1\.[0-9]+$
265 RewriteCond %{HTTPS} !=on
268 # Allow Network Access and/or Basic Auth
271 # Network Access Control
276 # HTTP Basic Authentication
278 AuthName "Protected Intranet Area"
279 AuthBasicProvider file
280 AuthUserFile conf/protected.passwd
286 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
287 <div class="section">
288 <h2><a name="logging" id="logging">Logging</a></h2>
291 <p><code class="module"><a href="../mod/mod_ssl.html">mod_ssl</a></code> can log extremely verbose debugging information
292 to the error log, when its <code class="directive"><a href="../mod/core.html#loglevel">LogLevel</a></code> is
293 set to the higher trace levels. On the other hand, on a very busy server,
294 level <code>info</code> may already be too much. Remember that you can
295 configure the <code class="directive"><a href="../mod/core.html#loglevel">LogLevel</a></code> per module to
296 suite your needs.</p>
298 <div class="bottomlang">
299 <p><span>Available Languages: </span><a href="../en/ssl/ssl_howto.html" title="English"> en </a> |
300 <a href="../fr/ssl/ssl_howto.html" hreflang="fr" rel="alternate" title="Français"> fr </a></p>
301 </div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
302 <script type="text/javascript"><!--//--><![CDATA[//><!--
303 var comments_shortname = 'httpd';
304 var comments_identifier = 'http://httpd.apache.org/docs/2.4/ssl/ssl_howto.html';
306 if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
307 d.write('<div id="comments_thread"><\/div>');
308 var s = d.createElement('script');
309 s.type = 'text/javascript';
311 s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
312 (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
315 d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
317 })(window, document);
318 //--><!]]></script></div><div id="footer">
319 <p class="apache">Copyright 2012 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
320 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
321 if (typeof(prettyPrint) !== 'undefined') {