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" />
12 <link href="../images/favicon.ico" rel="shortcut icon" /></head>
13 <body id="manual-page"><div id="page-header">
14 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
15 <p class="apache">Apache HTTP Server Version 2.0</p>
16 <img alt="" src="../images/feather.gif" /></div>
17 <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div>
19 <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.0</a> > <a href="./">SSL/TLS</a></div><div id="page-content"><div id="preamble"><h1>SSL/TLS Strong Encryption: How-To</h1>
21 <p><span>Available Languages: </span><a href="../en/ssl/ssl_howto.html" title="English"> en </a></p>
25 <p>The solution of this problem is trivial
26 and is left as an exercise for the reader.</p>
28 <p class="cite">-- <cite>Standard textbook cookie</cite></p>
31 <p>How to solve particular security constraints for an SSL-aware
32 webserver is not always obvious because of the coherences between SSL,
33 HTTP and Apache's way of processing requests. This chapter gives
34 instructions on how to solve such typical situations. Treat it as a first
35 step to find out the final solution, but always try to understand the
36 stuff before you use it. Nothing is worse than using a security solution
37 without knowing its restrictions and coherences.</p>
39 <div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#ciphersuites">Cipher Suites and Enforced Strong Security</a></li>
40 <li><img alt="" src="../images/down.gif" /> <a href="#accesscontrol">Client Authentication and Access Control</a></li>
42 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
44 <h2><a name="ciphersuites" id="ciphersuites">Cipher Suites and Enforced Strong Security</a></h2>
47 <li><a href="#realssl">SSLv2 only server</a></li>
48 <li><a href="#onlystrong">strong encryption only server</a></li>
49 <li><a href="#upgradeenc">server gated cryptography</a></li>
50 <li><a href="#strongurl">stronger per-directory requirements</a></li>
53 <h3><a name="realssl" id="realssl">How can I create a real SSLv2-only server?</a></h3>
55 <p>The following creates an SSL server which speaks only the SSLv2 protocol and
58 <div class="example"><h3>httpd.conf</h3><p><code>
59 SSLProtocol -all +SSLv2<br />
60 SSLCipherSuite SSLv2:+HIGH:+MEDIUM:+LOW:+EXP<br />
64 <h3><a name="onlystrong" id="onlystrong">How can I create an SSL server which accepts strong encryption
67 <p>The following enables only the seven strongest ciphers:</p>
68 <div class="example"><h3>httpd.conf</h3><p><code>
70 SSLCipherSuite HIGH:MEDIUM<br />
74 <h3><a name="upgradeenc" id="upgradeenc">How can I create an SSL server which accepts strong encryption
75 only, but allows export browsers to upgrade to stronger encryption?</a></h3>
77 <p>This facility is called Server Gated Cryptography (SGC) and details
78 you can find in the <code>README.GlobalID</code> document in the
79 mod_ssl distribution. In short: The server has a Global ID server
80 certificate, signed by a special CA certificate from Verisign which
81 enables strong encryption in export browsers. This works as following:
82 The browser connects with an export cipher, the server sends its Global
83 ID certificate, the browser verifies it and subsequently upgrades the
84 cipher suite before any HTTP communication takes place. The question
85 now is: How can we allow this upgrade, but enforce strong encryption.
86 Or in other words: Browser either have to initially connect with
87 strong encryption or have to upgrade to strong encryption, but are
88 not allowed to keep the export ciphers. The following does the trick:</p>
89 <div class="example"><h3>httpd.conf</h3><p><code>
90 # allow all ciphers for the initial handshake,<br />
91 # so export browsers can upgrade via SGC facility<br />
92 SSLCipherSuite ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL<br />
94 <Directory /usr/local/apache2/htdocs><br />
95 # but finally deny all browsers which haven't upgraded<br />
96 SSLRequire %{SSL_CIPHER_USEKEYSIZE} >= 128<br />
101 <h3><a name="strongurl" id="strongurl">How can I create an SSL server which accepts all types of ciphers
102 in general, but requires a strong ciphers for access to a particular
105 <p>Obviously you cannot just use a server-wide <code class="directive"><a href="../mod/mod_ssl.html#sslciphersuite">SSLCipherSuite</a></code> which restricts the
106 ciphers to the strong variants. But mod_ssl allows you to reconfigure
107 the cipher suite in per-directory context and automatically forces
108 a renegotiation of the SSL parameters to meet the new configuration.
109 So, the solution is:</p>
110 <div class="example"><p><code>
111 # be liberal in general<br />
112 SSLCipherSuite ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL<br />
114 <Location /strong/area><br />
115 # but https://hostname/strong/area/ and below<br />
116 # requires strong ciphers<br />
117 SSLCipherSuite HIGH:MEDIUM<br />
121 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
122 <div class="section">
123 <h2><a name="accesscontrol" id="accesscontrol">Client Authentication and Access Control</a></h2>
126 <li><a href="#allclients">simple certificate-based client authentication</a></li>
127 <li><a href="#arbitraryclients">selective certificate-based client authentication</a></li>
128 <li><a href="#certauthenticate">particular certificate-based client authentication</a></li>
129 <li><a href="#intranet">intranet vs. internet authentication</a></li>
132 <h3><a name="allclients" id="allclients">How can I authenticate clients based on certificates when I know
133 all my clients?</a></h3>
135 <p>When you know your user community (i.e. a closed user group
136 situation), as it's the case for instance in an Intranet, you can
137 use plain certificate authentication. All you have to do is to
138 create client certificates signed by your own CA certificate
139 <code>ca.crt</code> and then verify the clients against this
141 <div class="example"><h3>httpd.conf</h3><p><code>
142 # require a client certificate which has to be directly<br />
143 # signed by our CA certificate in ca.crt<br />
144 SSLVerifyClient require<br />
145 SSLVerifyDepth 1<br />
146 SSLCACertificateFile conf/ssl.crt/ca.crt
150 <h3><a name="arbitraryclients" id="arbitraryclients">How can I authenticate my clients for a particular URL based on
151 certificates but still allow arbitrary clients to access the remaining
152 parts of the server?</a></h3>
154 <p>For this we again use the per-directory reconfiguration feature
155 of <code class="module"><a href="../mod/mod_ssl.html">mod_ssl</a></code>:</p>
157 <div class="example"><h3>httpd.conf</h3><p><code>
158 SSLVerifyClient none<br />
159 SSLCACertificateFile conf/ssl.crt/ca.crt<br />
161 <Location /secure/area><br />
162 SSLVerifyClient require<br />
163 SSLVerifyDepth 1<br />
164 </Location><br />
168 <h3><a name="certauthenticate" id="certauthenticate">How can I authenticate only particular clients for a some URLs based
169 on certificates but still allow arbitrary clients to access the remaining
170 parts of the server?</a></h3>
172 <p>The key is to check for various ingredients of the client certificate.
173 Usually this means to check the whole or part of the Distinguished
174 Name (DN) of the Subject. For this two methods exists: The <code class="module"><a href="../mod/mod_auth.html">mod_auth</a></code> based variant and the <code class="directive"><a href="../mod/mod_ssl.html#sslrequire">SSLRequire</a></code> variant. The first method is
175 good when the clients are of totally different type, i.e. when their
176 DNs have no common fields (usually the organisation, etc.). In this
177 case you've to establish a password database containing <em>all</em>
178 clients. The second method is better when your clients are all part of
179 a common hierarchy which is encoded into the DN. Then you can match
180 them more easily.</p>
182 <p>The first method:</p>
183 <div class="example"><h3>httpd.conf</h3><pre>
185 <Directory /usr/local/apache2/htdocs/secure/area>
187 SSLVerifyClient require
189 SSLCACertificateFile conf/ssl.crt/ca.crt
190 SSLCACertificatePath conf/ssl.crt
191 SSLOptions +FakeBasicAuth
193 AuthName "Snake Oil Authentication"
195 AuthUserFile /usr/local/apache2/conf/httpd.passwd
197 </Directory></pre></div>
199 <p>The password used in this example is the DES encrypted string "password".
200 See the <code class="directive"><a href="../mod/mod_ssl.html#ssloptions">SSLOptions</a></code> docs for more
203 <div class="example"><h3>httpd.passwd</h3><pre>
204 /C=DE/L=Munich/O=Snake Oil, Ltd./OU=Staff/CN=Foo:xxj31ZMTZzkVA
205 /C=US/L=S.F./O=Snake Oil, Ltd./OU=CA/CN=Bar:xxj31ZMTZzkVA
206 /C=US/L=L.A./O=Snake Oil, Ltd./OU=Dev/CN=Quux:xxj31ZMTZzkVA</pre></div>
208 <p>The second method:</p>
210 <div class="example"><h3>httpd.conf</h3><pre>
212 <Directory /usr/local/apache2/htdocs/secure/area>
214 SSLVerifyClient require
216 SSLCACertificateFile conf/ssl.crt/ca.crt
217 SSLCACertificatePath conf/ssl.crt
218 SSLOptions +FakeBasicAuth
220 SSLRequire %{SSL_CLIENT_S_DN_O} eq "Snake Oil, Ltd." \
221 and %{SSL_CLIENT_S_DN_OU} in {"Staff", "CA", "Dev"}
222 </Directory></pre></div>
225 <h3><a name="intranet" id="intranet">How can I require HTTPS with strong ciphers and either basic
226 authentication or client certificates for access to a subarea on the
227 Intranet website for clients coming from the Internet but still allow
228 plain HTTP access for clients on the Intranet?</a></h3>
230 <p>Let us assume the Intranet can be distinguished through the IP
231 network 192.168.1.0/24 and the subarea on the Intranet website has
232 the URL <code>/subarea</code>. Then configure the following outside
233 your HTTPS virtual host (so it applies to both HTTPS and HTTP):</p>
235 <div class="example"><h3>httpd.conf</h3><pre>
236 SSLCACertificateFile conf/ssl.crt/company-ca.crt
238 <Directory /usr/local/apache2/htdocs>
239 # Outside the subarea only Intranet access is granted
242 Allow from 192.168.1.0/24
245 <Directory /usr/local/apache2/htdocs/subarea>
246 # Inside the subarea any Intranet access is allowed
247 # but from the Internet only HTTPS + Strong-Cipher + Password
248 # or the alternative HTTPS + Strong-Cipher + Client-Certificate
250 # If HTTPS is used, make sure a strong cipher is used.
251 # Additionally allow client certs as alternative to basic auth.
252 SSLVerifyClient optional
254 SSLOptions +FakeBasicAuth +StrictRequire
255 SSLRequire %{SSL_CIPHER_USEKEYSIZE} >= 128
257 # Force clients from the Internet to use HTTPS
259 RewriteCond %{REMOTE_ADDR} !^192\.168\.1\.[0-9]+$
260 RewriteCond %{HTTPS} !=on
263 # Allow Network Access and/or Basic Auth
266 # Network Access Control
271 # HTTP Basic Authentication
273 AuthName "Protected Intranet Area"
274 AuthUserFile conf/protected.passwd
276 </Directory></pre></div>
279 <div class="bottomlang">
280 <p><span>Available Languages: </span><a href="../en/ssl/ssl_howto.html" title="English"> en </a></p>
281 </div><div id="footer">
282 <p class="apache">Copyright 2009 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>
283 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div>