Debian Codegraph @

doc/howto/TLS.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>ProFTPD: FTP and SSL/TLS</title>
5 </head>
6
7 <body bgcolor=white>
8
9 <hr>
10 <center><h2><b>FTP and SSL/TLS</b></h2></center>
11 <hr>
12
13 <p>
14 RFC 4217 defines FTP over SSL/TLS:
15 <pre>
16 <a href="http://www.faqs.org/rfcs/rfc4217.html">http://www.faqs.org/rfcs/rfc4217.html</a>
17 </pre>
18 The <code>mod_tls</code> module for <code>proftpd</code> is an implementation
19 of RFC 4217.
20
21 <p>
22 <a href="http://www.faqs.org/rfcs/rfc2228.html">RFC 2228</a> defines FTP Security Extensions, of which <code>mod_tls</code> is one implementation. Another
23 such RFC 2228 implementation is the <code>mod_gss</code> module, available
24 from SourceForge.
25
26 <p>
27 Example <a href="../contrib/mod_tls.html"><code>mod_tls</code></a> configuration:
28 <pre>
29 &lt;IfModule mod_dso.c&gt;
30 <font color=green># If mod_tls was built as a shared/DSO module, load it</font>
31 LoadModule mod_tls.c
32 &lt;/IfModule&gt;
33
34 &lt;IfModule mod_tls.c&gt;
35 TLSEngine on
36 TLSLog /var/ftpd/tls.log
37
38 <font color=green># Support TLSv1, TLSv1.1, and TLSv1.2</font>
39 TLSProtocol TLSv1 TLSv1.1 TLSv1.2
40
41 <font color=green># Are clients required to use FTP over TLS when talking to this server?</font>
42 TLSRequired off
43
44 <font color=green># Server's RSA certificate</font>
45 TLSRSACertificateFile /etc/ftpd/server-rsa.cert.pem
46 TLSRSACertificateKeyFile /etc/ftpd/server-rsa.key.pem
47
48 <font color=green># Server's EC certificate</font>
49 TLSECCertificateFile /etc/ftpd/server-ec.cert.pem
50 TLSECCertificateKeyFile /etc/ftpd/server-ec.key.pem
51
52 <font color=green># CA the server trusts</font>
53 TLSCACertificateFile /etc/ftpd/root.cert.pem
54
55 <font color=green># Authenticate clients that want to use FTP over TLS?</font>
56 TLSVerifyClient off
57
58 <font color=green># Allow SSL/TLS renegotiations when the client requests them, but
59 # do not force the renegotiations. Some clients do not support
60 # SSL/TLS renegotiations; when mod_tls forces a renegotiation, these
61 # clients will close the data connection, or there will be a timeout
62 # on an idle data connection.</font>
63 TLSRenegotiate none
64
65 &lt;/IfModule&gt;
66 </pre>
67
68 <p><a name="TLSCertificates"></a>
69 <b>Managing Certificates</b><br>
70 Here are some widely used tools for generating and managing TLS certificates:
71 <ul>
72 <li><a href="https://certbot.eff.org/">Certbot</a>
73 <li><a href="https://letsencrypt.org/">Let's Encrypt</a>
74 </ul>
75
76 <p><a name="TLSDebugging"></a>
77 <b>Debugging</b><br>
78 There are a couple of tools available for debugging and analysing FTPS
79 traffic. One of the easiest to use is the <a href="http://www.openssl.org/docs/apps/s_client.html"><code>s_client</code></a> application, part of OpenSSL.
80
81 <p>
82 The following examples assume that <code>proftpd+mod_tls</code> is listening
83 on 127.0.0.1, port 21:
84 <pre>
85 # openssl s_client -connect 127.0.0.1:21 -starttls ftp
86 CONNECTED(00000003)
87 depth=1 /CN=castaglia3-serverCA/C=US/[email protected]/O=Castaglia/OU=Castaglia Research and Development/OU=TJ Saunders/ST=Washington
88 verify error:num=20:unable to get local issuer certificate
89 verify return:0
90 ---
91 <b>Certificate chain</b>
92 0 s:/CN=castaglia3-server/C=US/[email protected]/O=Castaglia/OU=Castaglia Research and Development/OU=TJ Saunders/ST=Washington
93 i:/CN=castaglia3-serverCA/C=US/[email protected]/O=Castaglia/OU=Castaglia Research and Development/OU=TJ Saunders/ST=Washington
94 1 s:/CN=castaglia3-serverCA/C=US/[email protected]/O=Castaglia/OU=Castaglia Research and Development/OU=TJ Saunders/ST=Washington
95 i:/CN=castaglia3/C=US/ST=Washington/L=Seattle/O=Castaglia/OU=Castaglia Research and Development/OU=TJ Saunders/[email protected]
96 ---
97 Server certificate
98 -----BEGIN CERTIFICATE-----
99 ...
100 -----END CERTIFICATE-----
101 subject=/CN=castaglia3-server/C=US/[email protected]/O=Castaglia/OU=Castaglia Research and Development/OU=TJ Saunders/ST=Washington
102 issuer=/CN=castaglia3-serverCA/C=US/[email protected]/O=Castaglia/OU=Castaglia Research and Development/OU=TJ Saunders/ST=Washington
103 ---
104 <b>Acceptable client certificate CA names</b>
105 /CN=castaglia3-clientCA/C=US/[email protected]/O=Castaglia/OU=Castaglia Research and Development/OU=TJ Saunders/ST=Washington
106 /CN=castaglia3/C=US/ST=Washington/L=Seattle/O=Castaglia/OU=Castaglia Research and Development/OU=TJ Saunders/[email protected]
107 /CN=castaglia3-clientCA/C=US/[email protected]/O=Castaglia/OU=Castaglia Research and Development/OU=TJ Saunders/ST=Washington
108 /CN=castaglia3/C=US/ST=Washington/L=Seattle/O=Castaglia/OU=Castaglia Research and Development/OU=TJ Saunders/[email protected]
109 ---
110 SSL handshake has read 3731 bytes and written 344 bytes
111 ---
112 New, TLSv1/SSLv3, Cipher is DHE-RSA-AES256-SHA
113 Server public key is 1024 bit
114 Compression: NONE
115 Expansion: NONE
116 SSL-Session:
117 Protocol : TLSv1
118 Cipher : DHE-RSA-AES256-SHA
119 Session-ID: D1F2E7C001BCFE57D797F34BD1518BDCC6160106D56A238CC0F957337C093435
120 Session-ID-ctx:
121 Master-Key: F8EE2812270E8FCD87D1B26F20546EF9BABAE40F36BC6F8DF45B0E2F089571E731EAFAEA5E61BCA7D9D204BE06F28B21
122 Key-Arg : None
123 Start Time: 1232997620
124 Timeout : 300 (sec)
125 Verify return code: 20 (unable to get local issuer certificate)
126 ---
127 220 ProFTPD 1.3.2rc4 Server (TJ's FTPS Server) [127.0.0.1]
128 quit
129 221 Goodbye.
130 read:errno=0
131 </pre>
132 Note that the "verify error" message is not of particular concern for us,
133 since we are not using <code>s_client</code> to verify the server's
134 certificate in this example.
135
136 <p>
137 The parts of the <code>s_client</code> output which are of particular interest
138 are the highlighted "Certificate chain" and "Acceptable client certificate CA
139 names" sections.
140
141 <p>
142 The "Certificate chain" section shows the certificate chain/trust path, from
143 the server's certificate up through the root CA for that certificate. Note
144 that this assumes the certificates in the trust path are available on the
145 server. By default, OpenSSL constructs this certificate chain using the
146 server's certificate (configured using <code>TLSRSACertificateFile</code> or
147 <code>TLSDSACertificateFile</code>) and the trusted CA certificates configured
148 using <code>TLSCACertificateFile</code> and/or
149 <code>TLSCACertificatePath</code>. See the <code>TLSCertificateChainFile</code>
150 <a href="#TLSCertificateChainFile">FAQ</a> for more details on how to influence
151 the constructed certificate chain.
152
153 <p>
154 The "Acceptable client certificate CA names" section contains the list of
155 CAs that can issue certificates that <code>mod_tls</code> is willing to trust.
156 These CAs <i>always</i> come from the configured
157 <code>TLSCACertificateFile</code> and/or <code>TLSCACertificatePath</code>.
158 This list of acceptable client CAs is presented to the client whenever the
159 server is requesting the client's certificate (which is what
160 <code>mod_tls</code> does by default). If you use:
161 <pre>
162 TLSOptions NoCertRequest
163 </pre>
164 then the server <i>will not</i> send this list of acceptable client CAs;
165 using <code>s_client</code> in that case, you would see:
166 <pre>
167 ---
168 No client certificate CA names sent
169 ---
170 </pre>
171 In case you're wondering, a list of CAs is sent to the client, rather than
172 just a single CA, because this allows clients the ability to determine which
173 certificate (as a client can have many) to use when talking to this particular
174 server.
175
176 <p>
177 Another tool, slightly older, is <a href="http://www.rtfm.com/ssldump/"><code>ssldump</code></a>. This tool is more like <code>ethereal</code> or
178 <code>tcpdump</code> for any SSL/TLS traffic; it is deliberately modeled after
179 <code>tcpdump</code>.
180
181 <p>
182 To use <code>ssldump</code> for watching your FTPS traffic, you will need
183 the server key file (for decrypting), and possibly root privileges (for
184 listening on the network interface). Here is an example where
185 <code>ssldump</code> is used to listen on the loopback interface
186 (<code>lo0</code>), port 21:
187 <pre>
188 # sudo ssldump -d -k <i>server</i>.pem -i lo0 port 21
189 New TCP connection #1: localhost(64148) &lt;-&gt; localhost(21)
190 0.0423 (0.0423) S&gt;C
191 ---------------------------------------------------------------
192 220 ProFTPD 1.3.2rc4 Server (TJ's FTPS Server) [127.0.0.1]
193 ---------------------------------------------------------------
194
195 0.0427 (0.0004) C&gt;S
196 ---------------------------------------------------------------
197 AUTH TLS
198 ---------------------------------------------------------------
199
200 0.0430 (0.0002) S&gt;C
201 ---------------------------------------------------------------
202 234 AUTH TLS successful
203 ---------------------------------------------------------------
204
205 1 1 0.0433 (0.0003) C&gt;S SSLv2 compatible client hello
206 Version 3.1
207 cipher suites
208 Unknown value 0x39
209 Unknown value 0x38
210 Unknown value 0x35
211 TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA
212 TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA
213 TLS_RSA_WITH_3DES_EDE_CBC_SHA
214 SSL2_CK_3DES
215 Unknown value 0x33
216 Unknown value 0x32
217 Unknown value 0x2f
218 TLS_RSA_WITH_IDEA_CBC_SHA
219 SSL2_CK_IDEA
220 SSL2_CK_RC2
221 TLS_RSA_WITH_RC4_128_SHA
222 TLS_RSA_WITH_RC4_128_MD5
223 SSL2_CK_RC4
224 TLS_DHE_RSA_WITH_DES_CBC_SHA
225 TLS_DHE_DSS_WITH_DES_CBC_SHA
226 TLS_RSA_WITH_DES_CBC_SHA
227 SSL2_CK_DES
228 TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA
229 TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA
230 TLS_RSA_EXPORT_WITH_DES40_CBC_SHA
231 TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5
232 SSL2_CK_RC2_EXPORT40
233 TLS_RSA_EXPORT_WITH_RC4_40_MD5
234 SSL2_CK_RC4_EXPORT40
235 1 2 0.0658 (0.0225) S&gt;C Handshake
236 ServerHello
237 Version 3.1
238 session_id[32]=
239 09 25 df 7a a8 e8 71 a2 9f 56 a6 7b dd 95 ac 67
240 7d 2e 81 b2 1c ca b4 5f 1e 95 13 47 01 28 20 19
241 cipherSuite Unknown value 0x39
242 compressionMethod NULL
243 1 3 0.0658 (0.0000) S&gt;C Handshake
244 Certificate
245 1 4 0.0658 (0.0000) S&gt;C Handshake
246 ServerKeyExchange
247 1 5 0.0658 (0.0000) S&gt;C Handshake
248 CertificateRequest
249 certificate_types rsa_fixed_dh
250 certificate_types dss_fixed_dh
251 certificate_types rsa_sign
252 certificate_types dss_sign
253 certificate_authority
254 30 81 b8 31 1c 30 1a 06 03 55 04 03 13 13 63 61
255 73 74 61 67 6c 69 61 33 2d 63 6c 69 65 6e 74 43
256 41 31 0b 30 09 06 03 55 04 06 13 02 55 53 31 1f
257 30 1d 06 09 2a 86 48 86 f7 0d 01 09 01 16 10 74
258 6a 40 63 61 73 74 61 67 6c 69 61 2e 6f 72 67 31
259 12 30 10 06 03 55 04 0a 13 09 43 61 73 74 61 67
260 6c 69 61 31 2b 30 29 06 03 55 04 0b 13 22 43 61
261 73 74 61 67 6c 69 61 20 52 65 73 65 61 72 63 68
262 20 61 6e 64 20 44 65 76 65 6c 6f 70 6d 65 6e 74
263 31 14 30 12 06 03 55 04 0b 13 0b 54 4a 20 53 61
264 75 6e 64 65 72 73 31 13 30 11 06 03 55 04 08 13
265 0a 57 61 73 68 69 6e 67 74 6f 6e
266 certificate_authority
267 30 81 c1 31 13 30 11 06 03 55 04 03 13 0a 63 61
268 73 74 61 67 6c 69 61 33 31 0b 30 09 06 03 55 04
269 06 13 02 55 53 31 13 30 11 06 03 55 04 08 13 0a
270 57 61 73 68 69 6e 67 74 6f 6e 31 10 30 0e 06 03
271 55 04 07 13 07 53 65 61 74 74 6c 65 31 12 30 10
272 06 03 55 04 0a 13 09 43 61 73 74 61 67 6c 69 61
273 31 2b 30 29 06 03 55 04 0b 13 22 43 61 73 74 61
274 67 6c 69 61 20 52 65 73 65 61 72 63 68 20 61 6e
275 64 20 44 65 76 65 6c 6f 70 6d 65 6e 74 31 14 30
276 12 06 03 55 04 0b 13 0b 54 4a 20 53 61 75 6e 64
277 65 72 73 31 1f 30 1d 06 09 2a 86 48 86 f7 0d 01
278 09 01 16 10 74 6a 40 63 61 73 74 61 67 6c 69 61
279 2e 6f 72 67
280 certificate_authority
281 30 81 b8 31 1c 30 1a 06 03 55 04 03 13 13 63 61
282 73 74 61 67 6c 69 61 33 2d 63 6c 69 65 6e 74 43
283 41 31 0b 30 09 06 03 55 04 06 13 02 55 53 31 1f
284 30 1d 06 09 2a 86 48 86 f7 0d 01 09 01 16 10 74
285 6a 40 63 61 73 74 61 67 6c 69 61 2e 6f 72 67 31
286 12 30 10 06 03 55 04 0a 13 09 43 61 73 74 61 67
287 6c 69 61 31 2b 30 29 06 03 55 04 0b 13 22 43 61
288 73 74 61 67 6c 69 61 20 52 65 73 65 61 72 63 68
289 20 61 6e 64 20 44 65 76 65 6c 6f 70 6d 65 6e 74
290 31 14 30 12 06 03 55 04 0b 13 0b 54 4a 20 53 61
291 75 6e 64 65 72 73 31 13 30 11 06 03 55 04 08 13
292 0a 57 61 73 68 69 6e 67 74 6f 6e
293 certificate_authority
294 30 81 c1 31 13 30 11 06 03 55 04 03 13 0a 63 61
295 73 74 61 67 6c 69 61 33 31 0b 30 09 06 03 55 04
296 06 13 02 55 53 31 13 30 11 06 03 55 04 08 13 0a
297 57 61 73 68 69 6e 67 74 6f 6e 31 10 30 0e 06 03
298 55 04 07 13 07 53 65 61 74 74 6c 65 31 12 30 10
299 06 03 55 04 0a 13 09 43 61 73 74 61 67 6c 69 61
300 31 2b 30 29 06 03 55 04 0b 13 22 43 61 73 74 61
301 67 6c 69 61 20 52 65 73 65 61 72 63 68 20 61 6e
302 64 20 44 65 76 65 6c 6f 70 6d 65 6e 74 31 14 30
303 12 06 03 55 04 0b 13 0b 54 4a 20 53 61 75 6e 64
304 65 72 73 31 1f 30 1d 06 09 2a 86 48 86 f7 0d 01
305 09 01 16 10 74 6a 40 63 61 73 74 61 67 6c 69 61
306 2e 6f 72 67
307 ServerHelloDone
308 1 6 0.1005 (0.0346) C&gt;S Handshake
309 Certificate
310 1 7 0.1005 (0.0000) C&gt;S Handshake
311 ClientKeyExchange
312 1 8 0.1005 (0.0000) C&gt;S ChangeCipherSpec
313 1 9 0.1005 (0.0000) C&gt;S Handshake
314 1 10 0.1164 (0.0159) S&gt;C ChangeCipherSpec
315 1 11 0.1164 (0.0000) S&gt;C Handshake
316 1 12 1.7856 (1.6692) C&gt;S application_data
317 1 13 1.7856 (0.0000) C&gt;S application_data
318 1 14 1.7861 (0.0004) S&gt;C application_data
319 1 1.7866 (0.0004) S&gt;C TCP FIN
320 1 15 1.7868 (0.0002) C&gt;S Alert
321 </pre>
322
323 <p>
324 As you can see, the level of granularity used by <code>ssldump</code> is on
325 the level of each SSL/TLS packet; while useful in some cases, I suspect that
326 using <code>openssl s_client</code> will provide most of the information you
327 will want in figuring out your certificate and verification issues.
328
329 <p><a name="TLSClientAuth"></a>
330 <b>TLS Client Auth/Mutual Auth</b><br>
331 Like most web servers, when <code>mod_tls</code> is used, it does not
332 require that the connecting client present a certificate for verification
333 by default. That is, <code>mod_tls</code> does not require "client auth"
334 or "mutual auth" by default. To require that clients present a valid
335 certificate, you would use the <a href="../contrib/mod_tls.html#TLSVerifyClient"><code>TLSVerifyClient</code></a> directive like so:
336 <pre>
337 &lt;IfModule mod_tls.c&gt;
338 TLSEngine on
339 ...
340 <font color=green># Verify clients that want to use FTP over TLS</font>
341 TLSVerifyClient on
342 &lt;/IfModule&gt;
343 </pre>
344
345 <p>
346 With this directive enabled in your configuration, if a client connects
347 and performs the SSL/TLS handshake but does <b>not</b> present a valid
348 certificate, then the TLSLog would contain error messages like this:
349 <pre>
350 mod_tls/2.4.3[12065]: TLS/TLS-C requested, starting TLS handshake
351 mod_tls/2.4.3[12065]: unable to accept TLS connection: protocol error:
352 (1) error:140890C7:SSL routines:SSL3_GET_CLIENT_CERTIFICATE:peer did not return a certificate
353 mod_tls/2.4.3[12065]: TLS/TLS-C negotiation failed on control channel
354 </pre>
355 The client failed to provide a valid certificate, and so the connection
356 was rejected.
357
358 <p><a name="FAQ"></a>
359 <b>Frequently Asked Questions</b><br>
360
361 <p><a name="TLSDataTransfer">
362 <font color=red>Question</font>: When I enable <code>mod_tls</code>,
363 I can't upload or download files, or list directories. I see the following
364 error in my client:
365 <pre>
366 425 Unable to build data connection: Operation not permitted.
367 </pre>
368 Why?<br>
369 <font color=blue>Answer</font>: By default, <code>mod_tls</code> requires
370 that the same SSL session be used data transfers (see
371 <a href="../contrib/mod_tls.html#TLSOptions"><code>TLSOptions</code></a>),
372 which includes uploads, downloads, <i>and</i> directory listings. If your
373 data transfers are failing, you might look in your
374 <a href="../contrib/mod_tls.html#TLSLog"><code>TLSLog</code></a>, and see
375 a log message like this:
376 <pre>
377 client did not reuse SSL session, rejecting data connection (see the NoSessionReuseRequired TLSOptions parameter)
378 </pre>
379 The workaround, then, is to add the TLSOption mentioned in the log message
380 to your configuration, <i>i.e.</i>:
381 <pre>
382 # Relax the requirement that the SSL session be reused for data transfers
383 TLSOptions NoSessionReuseRequired
384 </pre>
385 Then restart <code>proftpd</code>, and your data transfers should work.
386
387 <p><a name="TLSCertificateGeneration">
388 <font color=red>Question</font>: How do I generate the certificate files used
389 by <code>mod_tls</code>?<br>
390 <font color=blue>Answer</font>: The <code>mod_tls</code> module uses the
391 same certificate files as Apache's <code>mod_ssl</code>. The
392 <code>mod_ssl</code> documentation explains what the files are, how they
393 are used, and how to generate your own:
394 <pre>
395 <a href="http://www.modssl.org/docs/2.7/ssl_faq.html#ToC24">http://www.modssl.org/docs/2.7/ssl_faq.html</a>
396 </pre>
397
398 <p><a name="TLSProtection">
399 <font color=red>Question</font>: Does FTPS protect both the control connection
400 <b>and</b> the data connections?<br>
401 <font color=blue>Question</font>: Short answer: yes.
402
403 <p>
404 The long answer is, of course, that it depends. In the case of
405 <code>mod_tls</code>, it depends on your <code>TLSRequired</code> setting.
406 If you use:
407 <pre>
408 TLSRequired on
409 </pre>
410 then you are configuring <code>mod_tls</code> to <b>require</b> SSL/TLS
411 protection for both control connections (<i>e.g.</i> protecting the username
412 and password used to log in) <i>and</i> data connections. If you have:
413 <pre>
414 TLSRequired off
415 </pre>
416 then it is up to the FTPS client whether both control and data connections
417 will be protected via SSL/TLS. Other <code>TLSRequired</code> settings
418 can be used to specify specific combinations: data connections only,
419 control connections only, authentication plus data data connections only,
420 <i>etc</i>. The <code>TLSRequired</code>
421 <a href="../../contrib/mod_tls.html#TLSRequired">documentation</a> has the
422 details.
423
424 <p><a name="TLSClients">
425 <font color=red>Question</font>: Where can I find a list of clients that
426 support FTPS?<br>
427 <font color=blue>Answer</font>: This page is a good FTPS resource:
428 <pre>
429 <a href="http://www.ford-hutchinson.com/~fh-1-pfh/ftps-ext.html">http://www.ford-hutchinson.com/~fh-1-pfh/ftps-ext.html</a>
430 </pre>
431 including the list of FTPS <a href="http://www.ford-hutchinson.com/~fh-1-pfh/ftps-ext.html#client">clients</a>. On a related note, there have been some
432 reports that Debian's <code>ftp-ssl</code> client has a few bugs; using Peter
433 Runestig's <code>ftp-tls</code> is known to work.
434
435 <p>
436 Note, though, that there are known issues with some older versions of FTPS
437 clients, most notably SmartFTP and CuteFTP Pro. These clients had the following
438 behavior: <a href="http://www.faqs.org/rfcs/rfc2246.html">RFC 2246</a> states
439 that, if a client receives a <code>CertificateRequest</code>, and the client
440 has no certificate, it "should send a certificate message containing no
441 certificates" (Section 7.4.6). Instead, after negotiating to use TLS version 1,
442 these clients choke and break the connection (which is actually SSL version 2
443 behavior). The <code>NoCertRequest</code> <a href="../contrib/mod_tls.html#TLSOptions"><code>TLSOption</code></a> is designed for use for such clients.
444
445 <p><a name="TLSImplicit">
446 <font color=red>Question</font>: How come <code>mod_tls</code> does not support
447 &quot;implicit&quot; FTPS (<i>i.e.</i> automatically encrypting sessions on
448 port 990)?<br>
449 <font color=blue>Answer</font>: The short answer is because the Draft no longer
450 specifies support for such a mode. Here is a <a href="http://www.ford-hutchinson.com/~fh-1-pfh/ftps-ext.html#bad">description</a> of why the alternatives
451 to the current mode (client-requested encryption using standard control
452 channel) are &quot;bad&quot;.
453
454 <p>
455 The long answer is covered in Eric Rescorla's excellent book, <a href="http://www.rtfm.com/sslbook/">&quot;SSL and TLS&quot;</a>. There tend to be two
456 different strategies used when adding new features to a protocol: separate
457 ports for protocol variants, or upward negotiation. Port 443 for HTTPS is an
458 example of the separate ports strategy. The drawback to the separate ports
459 approach is that there is a finite number of ports available, and so this
460 approach does not scale well. The benefit is that use of separate ports tends
461 to require smaller changes to client and server code. Upward negotiation
462 is more flexible, but requires that the protocol support some sort of feature
463 negotiation or extension discovery, allowing clients and servers to easily
464 agree to negotiate &quot;upward&quot; into a secure channel. The authors
465 of the FTPS Draft felt that upward negotiation was the more appropriate of
466 these two approaches for encrypting FTP channels.
467
468 <p>
469 All that said, in ProFTPD 1.3.3rc2, the <code>mod_tls</code> module was
470 enhanced to support implicit FTPS via the <code>UseImplicitSSL</code>
471 <a href="../contrib/mod_tls.html#TLSOption"><code>TLSOption</code></a>.
472
473 <p><a name="TLSv1.2">
474 <font color=red>Question</font>: How can I require that <b>only</b> TLSv1.2
475 be allowed/used?<br>
476 <font color=blue>Answer</font>: Assuming your OpenSSL library is new enough,
477 you should only need to use the following in your <code>mod_tls</code>
478 configuration section:
479 <pre>
480 TLSProtocol TLSv1.2
481 </pre>
482 Note that if you have multiple <code>&lt;VirtualHost&gt;</code> sections in
483 your <code>proftpd.conf</code> and you want this to apply to <em>all</em> of
484 those vhosts, then you should place the <code>TLSProtocol</code> directive
485 in a <code>&lt;Global&gt;</code> section, <i>e.g.</i>:
486 <pre>
487 &lt;Global&gt;
488 # Only allow TLSv1.2 for any of our FTPS vhosts
489 TLSProtocol TLSv1.2
490 &lt;/Global&gt;
491 </pre>
492
493 <p><a name="TLSPerUser">
494 <font color=red>Question</font>: Can I require TLS on a per-user basis?<br>
495 <font color=blue>Answer</font>: Prior to ProFTPD 1.2.10rc2, no. The IETF
496 Draft specifying FTP over TLS requires that the TLS handshake occur
497 <i>before</i> the client sends the <code>USER</code> command. This means that
498 the server does not know the name of the user that the client will be using
499 when the TLS session is established. It is possible that the client's
500 certificate, if one is even presented, may contain information the server may
501 use to map that certificate to a user, but such mapping is not currently
502 supported by <code>mod_tls</code>. Note that this is also the reason the
503 <code>TLSRequired</code> directive cannot appear in the
504 <code>&lt;Anonymous&gt;</code> context: anonymous logins are based on the
505 <code>USER</code> command.
506
507 <p>
508 However, in 1.2.10rc2, the <code>mod_tls</code> module was modified to allow
509 such per-user TLS requirements. To do this, the <code>AllowPerUser</code>
510 parameter of the <code>TLSOptions</code> directive is used. For example,
511 the following example <code>mod_tls</code> configuration allows non-SSL
512 anonymous sessions, but requires SSL/TLS for all other sessions:
513 <pre>
514 &lt;IfModule mod_tls.c&gt;
515 TLSEngine on
516 TLSRSACertificateFile ...
517 TLSCACertificateFile ...
518 TLSOptions AllowPerUser
519 TLSRequired on
520
521 &lt;Anonymous ~ftp&gt;
522 User ftp
523 Group ftp
524 UserAlias anonymous ftp
525
526 RequireValidShell off
527
528 # Note how TLSRequired is set to off here in the &lt;Anonymous&gt; context
529 TLSRequired off
530 &lt;/Anonymous&gt;
531 &lt;/IfModule&gt;
532 </pre>
533 The modification also allows <code>mod_ifsession</code>-based conditions, so
534 that one can have settings like:
535 <pre>
536 &lt;IfGroup trusted&gt;
537 TLSRequired off
538 &lt;/IfGroup&gt;
539 </pre>
540 However, there is a risk involved in using the <code>AllowPerUser</code>
541 option: it causes <code>mod_tls</code> not to enforce <code>TLSRequired</code>
542 until <i>after</i> the potentially sensitive USER and PASS commands have
543 been sent by the client. This allows clients, even when
544 <code>TLSRequired on</code> or <code>TLSRequired ctrl</code> are in effect,
545 to send the USER and PASS commands <i>unencrypted</i>. Depending on your
546 site's security needs, the ability to require SSL/TLS on a per-user basis
547 may or may not be worth the ability to require SSL/TLS for the USER and PASS
548 commands.
549
550 <p><a name="TLSRequiredPlusPerUser">
551 <font color=red>Question</font>: When I use the following in my
552 <code>proftpd.conf</code>:
553 <pre>
554 TLSRequired on <font color=green># or "TLSRequired auth", or "TLSRequired auth+data"</font>
555 TLSOptions AllowPerUser
556 </pre>
557 I get the following error when I try to start <code>proftpd</code>:
558 <pre>
559 cannot enforce both 'TLSRequired auth' and 'TLSOptions AllowPerUser' at the same time
560 </pre>
561 <font color=blue>Answer</font>: The reason this error occurs is because
562 you have a configuration which is impossible to support. The
563 <code>TLSRequired</code> setting (<i>e.g.</i> "on", "auth", or "auth+data")
564 requires that SSL/TLS be in use during authentication. But in order to
565 support the <code>TLSOption AllowPerUser</code> setting, the
566 <code>mod_tls</code> <b>cannot</b> require that SSL/TLS be in use during
567 authentication, since it does not know the user until <i>after</i>
568 authentication has completed. The requested configuration cannot be supported,
569 and thus the server will refuse to start.
570
571 <p><a name="TLSFXP">
572 <font color=red>Question</font>: Why does <code>mod_tls</code> break FXP
573 transfers?<br>
574 <font color=blue>Answer</font>: The Draft specifying FTP over SSL explicitly
575 omits site-to-site transfers. A TLS session is established between the client
576 and the server on the control channel and, to save on the expensive overhead of
577 TLS handshake, that session is reused for encrypting traffic on the data
578 channel. In a site-to-site (FXP) transfer, the client opens <i>two</i> control
579 channels, one with each server, and then arranges for those servers to open a
580 data channel between themselves. However, since the servers have not
581 established a TLS session between themselves, that opening of the data channel
582 fails.
583
584 <p>
585 Note that the above happens only if the server requires that TLS be used on data
586 connections (<i>e.g.</i> <code>TLSRequired</code> is either <em>on</em> or
587 <em>data</em>), of if the client tells the server that the client will be
588 using TLS on the data connections (<i>e.g.</i> when it sends the
589 <code>AUTH</code> command with an argument of <code>TLS-P</code>). Without
590 these conditions, site-to-site (FXP) transfers can occur normally, albeit
591 unencrypted.
592
593 <p>
594 <b>Note</b> that as of <code>proftpd-1.3.5rc4</code>, encrypted site-to-site
595 (FXP) transfers are supported via the <code>SSCN</code> FTP command. The
596 <a href="../contrib/mod_tls.html#TLSVerifyServer"><code>TLSVerifyServer</code></a> directive is also needed for secure FXP transfers.
597
598 <p><a name="SSLv2">
599 <font color=red>Question</font>: How come <code>mod_tls</code> does not support
600 SSLv2?<br>
601 <font color=blue>Answer</font>: Various defects have been found in the SSLv2
602 protocol. Some legacy sites need to support SSLv2 for their HTTP traffic, in
603 spite of its flaws. Use of FTP over TLS is fairly new, however, and there is
604 not much &quot;legacy&quot; in that regard; it was felt that, as
605 <code>mod_tls</code> aims to provide strong cryptographic security, supporting
606 a known bad protocol is a Bad Idea.
607
608 <p><a name="TLSFirewall">
609 <font color=red>Question</font>: Using <code>mod_tls</code>, FTP sessions
610 through my firewall now no longer work. What's going on?<br>
611 <font color=blue>Answer</font>: The short answer is that FTPS and firewalls
612 (and devices performing NAT) do not interact well. The control connection
613 happens on a well-known port, and has no issues; it is the data connection
614 that poses problems for FTP-aware firewalls. In a non-FTPS session, the
615 firewall can inspect the FTP server's responses on the control connection to a
616 client's <code>PASV</code> or <code>PORT</code> command, and thus know which
617 on which ports/addresses the data connection will be established. In an FTPS
618 session, though, those control connection messages are encrypted (that is the
619 point of using FTPS, right?), and so the FTP-aware firewall cannot peek.
620 Hence, it cannot know which on which ports the data connection will be
621 established. For firewalls that are configured to always allow a certain
622 range of ports (such as might be configured using the <code>PassivePorts</code>
623 directive), FTPS should function without issue.
624
625 <p>
626 Unfortunately, this is a rather intractable--and known--issue. Earlier
627 versions of the Draft defining FTPS used to allow something known as
628 &quot;implicit&quot; FTPS, by which a client could contact a well-known port
629 (akin to port 443 for HTTPS; FTPS used port 990) and the server, simply
630 because the client contacted that certain port, would automatically encrypt
631 the session. This approach has several drawbacks (the reason why it was
632 removed from later versions of the Draft), but it <i>did</i> allow for simple
633 TCP proxying.
634
635 <p><a name="TLSCCC">
636 To attempt to deal with the above issue, the RFC for FTP over SSL/TLS
637 suggests using the <code>CCC</code> FTP command (<b>C</b>lear <b>C</b>ommand <b>C</b>hannel). The <code>CCC</code> command makes an encrypted control channel
638 revert back to an unencrypted channel. This helps to solve data connection
639 problems in situations where network equipment (such as firewalls, routers,
640 NAT) peek at the control channel in order to open ports. By sending the
641 <code>CCC</code> command and unecrypting the control channel, the network
642 equipment can once again peek at the commands (<i>i.e.</i> <code>PORT</code>
643 and <code>EPRT</code>) in the control channel. Since the CCC command must
644 come <em>after</em> the client has logged in, the <code>USER</code> and
645 <code>PASS</code> commands on the control channel will still be protected by
646 SSL/TLS.
647
648 <p>
649 Note that in order to configure the <code>mod_tls</code> module to allow use of
650 the <code>CCC</code> command by clients, the following must appear in your
651 <code>proftpd.conf</code>:
652 <pre>
653 TLSRequired auth+data
654 </pre>
655 See the <a href="../contrib/mod_tls.html#TLSRequired"><code>TLSRequired</code></a> description for more details.
656
657 <p><a name="TLSDataProtection">
658 <font color=red>Question</font>: I can login using FTPS, but I cannot see
659 any directories. Why not?<br>
660 <font color=blue>Answer</font>: You have most likely configured
661 <code>mod_tls</code> to require SSL/TLS protection for data transfers as
662 well as control commands, by using:
663 <pre>
664 TLSRequired on
665 </pre>
666 However, if your FTPS client does not expect to handle encrypted data
667 transfers (and directory listings count as data transfers, as they are
668 sent over a data channel), you may see your client appear to hang, waiting
669 for data it can read. Make sure your client is prepared to handle the
670 security requirements you have configured on the server.
671
672 <p>
673 The following may also appear in the <code>TLS</code> for any data
674 transfers (which include directory listings):
675 <pre>
676 client did not reuse SSL session, rejecting data connection (see the NoSessionReuseRequired TLSOptions parameter
677 </pre>
678 This message appears because an additional security restriction that was
679 added in ProFTPD 1.3.3rc1. The <a href="../contrib/mod_tls.html#TLSOptions"><code>TLSOptions</code></a> documentation for this "NoSessionReuseRequired" option
680 describes the situation in more detail.
681
682 <p>
683 You may also see the following appear in the <code>TLSLog</code> on occasion:
684 <pre>
685 PROT: unwilling to accept security parameter (C), declining
686 </pre>
687 The <code>PROT</code> FTP command is used to set the protection level to
688 be used for data transfers. Some clients send a <code>PROT</code> command
689 with a security parameter of <code>C</code>, meaning &quot;Clear&quot;,
690 which effectively tells the server not to protect data transfers. The
691 <code>mod_tls</code> module will refuse the <code>C</code> security parameter
692 if, like above, there is &quot;TLSRequired on&quot; in your
693 <code>proftpd.conf</code>. This case also indicates a disagreement between
694 the client's security expectations and the security policy you have configured
695 on the server.
696
697 <p>
698 In order to accept a &quot;PROT C&quot; FTP command, your <code>mod_tls</code>
699 configuration would need to use a <code>TLSRequired</code> value other than
700 <em>required</em>, <i>e.g.</i> something like:
701 <pre>
702 # We only require SSL/TLS protection during authentication
703 TLSRequired auth
704
705 # We will accept SSL/TLS protection for the control channel if the
706 # client wants to use it, but NOT for data transfers
707 TLSRequired !data
708 </pre>
709
710 <p><a name="TLSErrorAfterLargeUpload">
711 <font color=red>Question</font>: Using FTPS, after uploading a very large file,
712 my next directory listing fails:
713 <pre>
714 425 Unable to build data connection: Operation not permitted
715 </pre>
716 The <code>TLSLog</code> contains:
717 <pre>
718 client did not reuse SSL session, rejecting data connection (see the NoSessionReuseRequired TLSOptions parameter)
719 </pre>
720 but I do <i>not</i> want to use that option, and would like to rely on the
721 additional security protection provided by requring SSL session reuse.
722 And my FTPS client is correctly reusing SSL session IDs (as earlier data
723 transfers were working properly). So why is my data transfer failing after
724 the upload of a very large file?<br>
725 <font color=blue>Answer</font>: The answer involves SSL session caching
726 on the server side (<i>i.e.</i> <code>mod_tls</code>), cache timeouts, and
727 session renegotiations.
728
729 <p>
730 By default, <code>mod_tls</code> uses OpenSSL's "internal" session cache,
731 which is an in-memory caching of SSL session IDs. And by default, OpenSSL's
732 internal session cache has a cache timeout of 5 minutes; after that amount
733 of time in the internal session cache, a cached SSL session ID is considered
734 stale and is available for reuse.
735
736 <p>
737 This means that 5 minutes or more into an FTPS session, even if your FTPS
738 client reused an SSL session ID, the OpenSSL internal session cache will
739 time out that SSL session ID. The next time your FTPS client goes to reuse
740 that session ID for a data transfer, <code>mod_tls</code> won't find it in
741 the OpenSSL internal session cache, and will think that your FTPS client is
742 not reusing the SSL session ID as is required, and fail the transfer.
743
744 <p>
745 Fixing this situation requires two parts: <i>a)</i> the ability to change
746 the cache timeout used for the OpenSSL internal session cache, and <i>b)</i>
747 renegotiating the SSL session ID with the FTPS client periodically, to keep
748 the SSL session ID up-to-date in the session cache.
749
750 <p>
751 The first part, configuring the session cache timeout for the OpenSSL internal
752 session cache, is only possible in ProFTPD 1.3.4rc2 and later (see
753 <a href="http://bugs.proftpd.org/show_bug.cgi?id=3580">Bug#3580</a>). The
754 <a href="../contrib/mod_tls.html#TLSSessionCache"><code>TLSSessionCache</code></a> directive was modified to allow a configuration such as:
755 <pre>
756 TLSSessionCache internal: 1800
757 </pre>
758 (Unfortunately, the ':' after "internal" <i>is</i> necessary.) This configures
759 <code>mod_tls</code> such that the OpenSSL internal session cache uses
760 a cache timeout of 1800 seconds (30 minutes), rather than the default of 300
761 seconds (5 minutes).
762
763 <p>
764 No matter how long you configure the cache timeout, eventually you will have
765 a session which lasts longer than that timeout. Which brings us to the second
766 part of the solution: renegotiating a new SSL session ID periodically, which
767 keeps it fresh in the session cache. The
768 <a href="../contrib/mod_tls.html#TLSRenegotiate"><code>TLSRenegotiate</code></a>
769 directive is needed for this. For example, the following configuration
770 should address the issue of failed data transfers after very large uploads:
771 <pre>
772 TLSRenegotiate ctrl 1500 timeout 300
773 TLSSessionCache internal: 1800
774 </pre>
775 This tells <code>mod_tls</code> to request a renegotiation of the SSL session
776 on the control channel every 1500 seconds (25 minutes), and to allow
777 300 seconds (5 minutes) for the client to perform the renegotiation. It also
778 tells <code>mod_tls</code> to cache the SSL session data for 1800 seconds
779 (30 minutes), <i>i.e.</i> longer than the renegotiation time of 1500 seconds.
780
781 <p>
782 This way, as long as your client supports renegotiations and is updating the
783 SSL session ID properly for data transfers, when a data transfer is requested,
784 the SSL session ID presented by the client should always be fresh and in the
785 session cache.
786
787 <p><a name="TLSUnknownProtocol">
788 <font color=red>Question</font>: My FTPS client is failing to connect to
789 <code>proftpd</code> with <code>mod_tls</code>. The <code>TLSLog</code> shows
790 the following log messages, each time the FTPS client tries to connect:
791 <pre>
792 2016-01-15 07:32:37,275 mod_tls/2.7[5072]: TLS/TLS-C requested, starting TLS handshake
793 2016-01-15 07:32:37,303 mod_tls/2.7[5072]: unable to accept TLS connection: protocol error:
794 <b>(1) error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol</b>
795 2016-01-15 07:32:37,303 mod_tls/2.7[5072]: TLS/TLS-C negotiation failed on control channel
796 </pre>
797 Why does this happen?<br>
798 <font color=blue>Answer</font>: This can happen when <code>mod_tls</code> is
799 configured (<i>e.g.</i> using <code>TLSProtocol</code>) to support specific
800 TLS versions, and the FTPS client is trying to use one of the unsupported
801 protocol versions. For example, if you use:
802 <pre>
803 # Only support TLSv1.1 and TLSv1.2
804 TLSProtocol TLSv1.1 TLSv1.2
805 </pre>
806 And then connect with an FTPS client using TLSv1, like so:
807 <pre>
808 $ openssl s_client -connect <i>address</i>:<i>port</i> -starttls ftp -tls1
809 </pre>
810 Then you would see the above error. Note that this same protocol mismatch
811 issue can also manifest as the error message "wrong version number".
812
813 <p><a name="TLSBuildErrors">
814 <font color=red>Question</font>: Why would I see the following errors while attempting to build <code>proftpd</code> with <code>mod_tls</code>?
815 <pre>
816 /usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o)(.text+0x35): In function `dlfcn_load': : undefined reference to `dlopen'
817 /usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o)(.text+0x95): In function `dlfcn_load': : undefined reference to `dlclose'
818 /usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o)(.text+0xbc): In function `dlfcn_load': : undefined reference to `dlerror'
819 /usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o)(.text+0x147): In function `dlfcn_bind_var': : undefined reference to `dlsym'
820 /usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o)(.text+0x172): In function `dlfcn_bind_var': : undefined reference to `dlerror'
821 /usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o)(.text+0x237): In function `dlfcn_bind_func': : undefined reference to `dlsym'
822 /usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o)(.text+0x262): In function `dlfcn_bind_func': : undefined reference to `dlerror'
823 /usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o)(.text+0x50b): In function `dlfcn_unload': : undefined reference to `dlclose'
824 collect2: ld returned 1 exit status
825 make: *** [proftpd] Error 1
826 </pre>
827 <font color=blue>Answer</font>:
828 Add <code>-ldl</code> to your configure command, for example:
829 <pre>
830 make clean
831 ./configure LDFLAGS=-ldl ...
832 make
833 </pre>
834 This tells the <code>proftpd</code> build system to add <code>libdl</code>,
835 an OS-specific library for handling dynamically loaded code, to the list
836 of libraries used when linking <code>proftpd</code>. On some systems, the
837 functions in the <code>libdl</code> library are part of <code>libc</code>, and
838 are not in a separate library.
839
840 <p>
841 I suspect that the reason this build option may be necessary is that OpenSSL
842 0.9.8 contained changes regarding how OpenSSL loads "engines", software modules
843 that talk to hardware devices that can do specialized cryptographic operations.
844 These changes involve being able to dynamically load the "engine" software
845 modules.
846
847 <p><a name="TLSNoSharedCipher">
848 <font color=red>Question</font>: Why would I see a &quot;no shared cipher&quot; error in the TLSLog when attempting to connect with my FTPS client?<br>
849 <pre>
850 Jan 10 17:15:18 mod_tls/2.1.1[2212]: TLS/TLS-C requested, starting TLS handshake
851 Jan 10 17:15:18 mod_tls/2.1.1[2212]: unable to accept TLS connection:
852 (1) error:1408A0C1:SSL routines:SSL3_GET_CLIENT_HELLO:no shared cipher
853 Jan 10 17:15:18 mod_tls/2.1.1[2212]: TLS/TLS-C negotiation failed on control channel
854 </pre>
855 <font color=blue>Answer</font>:
856 There are two reasons this might happen.
857
858 <p>
859 The first is that there is indeed no ciphersuite in common between
860 <code>mod_tls</code> and your FTPS client. The SSL/TLS ciphersuites used by
861 <code>mod_tls</code> are configured using the <code>TLSCipherSuite</code>
862 directive. If you have a complex or restrictive <code>TLSCipherSuite</code>
863 configured, that could be the culprit. Try relaxing (or removing outright)
864 your <code>TLSCipherSuite</code>, or try to configure your FTPS client to use
865 the same SSL/TLS ciphersuites.
866
867 <p>
868 Another possibility is a misconfiguration. If your
869 <code>TLSCACertificateFile</code> and <code>TLSRSACertificateFile</code>
870 directives are in the &quot;server config&quot; context of the
871 <code>proftpd.conf</code> file, <i>and</i> you have
872 <code>&lt;VirtualHost&gt;</code> sections in your <code>proftpd.conf</code>,
873 then you might see the &quot;no shared cipher&quot; error. The easiest
874 thing is to move those <code>TLSCACertificateFile</code> and
875 <code>TLSRSACertificateFile</code> directives into a <code>&lt;Global&gt;</code>
876 section in your <code>proftpd.conf</code>, so that they apply to all
877 vhosts configured. The virtual hosting <a href="Vhost.html">howto</a>
878 describes this in more detail.
879
880 <p><a name="TLSClientCertChainTooLong">
881 <font color=red>Question</font>: When my FTPS client connects to my
882 <code>mod_tls</code>-enabled server, the TLS handshake fails. I see these
883 messages in my <code>TLSLog</code>:
884 <pre>
885 mod_tls/2.4.3[28786]: error: unable to verify certificate at depth 1
886 mod_tls/2.4.3[28786]: client certificate failed verification: certificate chain too long
887 </pre>
888 What causes this?<br>
889 <font color=blue>Answer</font>: This can happen if you have your
890 <code>mod_tls</code> configured with a very small <a href="../contrib/mod_tls.html#TLSVerifyDepth"><code>TLSVerifyDepth</code></a> value, <i>e.g.</i>:
891 <pre>
892 TLSVerifyDepth 0
893 </pre>
894 Using small values, especially a value of 0, is a <b>bad idea</b>; most client
895 certificate chains have a "depth" (or <em>length</em>) of 2-3, or perhaps
896 longer. The default <code>TLSVerifyDepth</code> value of 10 is sufficient for
897 most cases; it allows for long certificate chains, but still guards against
898 chains which might be absurdly long.
899
900 <p><a name="TLSRenegotiations">
901 <font color=red>Question</font>: My FTPS client sometimes times out after uploading/downloading more than 1 GB of data. When I turn off SSL/TLS, the upload/download works. Why?<br>
902 <font color=blue>Answer</font>:
903 The culprit behind this is most likely SSL/TLS renegotiations. By default,
904 <code>mod_tls</code> uses SSL/TLS renegotiations to periodically update the
905 session key which protects the data being transferred; see the
906 <a href="../contrib/mod_tls.html#TLSRenegotiate"><code>TLSRenegotiate</code></a> documentation for more details, particularly the time-based <i>and</i>
907 bytes-based limits at which renegotiations are forced.
908
909 <p>
910 Some FTPS clients, however, do not support server-initiated SSL/TLS
911 renegotiations. When the server does try to force a renegotiation, the client
912 fails that new handshake, cannot upload/download any more data over the
913 protected channel, and the transfer will eventually time out. Alternatively,
914 the transfer could terminate strangely in the middle of the upload/download.
915 <b>Note</b>, however, that not <i>all</i> transfer issues will be caused
916 by SSL/TLS renegotiations. Bugs in firewalls and routers can also cause
917 these symptoms.
918
919 <p>
920 Should you suspect that you are having issues with your FTPS client because
921 of SSL/TLS renegotiations, you can configure <code>mod_tls</code> to
922 accept renegotiations if the client requests one, but not to otherwise force
923 them:
924 <pre>
925 TLSRenegotiate required off
926 </pre>
927
928 <p><a name="TLSEOF">
929 <font color=red>Question</font>: My FTPS client has trouble connecting to <code>proftpd</code> using SSL/TLS, with the following error appearing in the <code>TLSLog</code>:
930 <pre>
931 mod_tls/2.1.2[9628]: TLS/TLS-C requested, starting TLS handshake
932 mod_tls/2.1.2[9628]: unable to accept TLS connection: received EOF that violates protocol
933 mod_tls/2.1.2[9628]: TLS/TLS-C negotiation failed on control channel
934 </pre>
935 Is this a bug in <code>mod_tls</code>, in the client, or something else?<br><br>
936 <font color=blue>Answer</font>: There might be several different causes for
937 this error. It could be a bug in the OpenSSL library, in <code>mod_tls</code>,
938 in the FTPS client, or it could be a transient network issue.
939
940 <p>
941 The <i>usual</i> culprit for the above error is an <em>FTP-aware</em> network
942 device such as a NAT, router, or firewall between the client and the server.
943 Such network devices "peek" into the FTP control connection in order to
944 dynamically open the necessary ports for data transfers. However, this
945 "peeking" fails once an SSL/TLS handshake starts on that same control
946 connection, and when that happens, these network devices usually terminate
947 the control connection, resulting in the EOF ("end of file") error reported.
948
949 <p><a name="TLSNoPassphrasePrompt">
950 <font color=red>Question</font>: When <code>proftpd</code> starts up, I am
951 prompted to enter the passphrases for my certificates. How can I get the
952 daemon to start without having to enter passphrases?<br>
953 <font color=blue>Answer</font>: You can either remove the passphrase from
954 the certificate key file (as mentioned in the Apache <code>mod_ssl</code>
955 <a href="http://www.modssl.org/docs/2.7/ssl_faq.html#remove-passphrase">FAQ</a>), or you can use the <code>TLSPassPhraseProvider</code> directive to configure
956 a program will which provide the passphrases to <code>proftpd</code>
957 automatically.
958
959 <p><a name="TLSFIPS">
960 <font color=red>Question</font>: How can I configure <code>mod_tls</code> to
961 use OpenSSL in FIPS mode?<br>
962 <font color=blue>Answer</font>: Using OpenSSL in FIPS mode requires quite
963 a few steps. First, you would configure <code>proftpd</code> to use the
964 <code>mod_tls</code> module as normal, assuming your OpenSSL installation
965 has been compiled with FIPS support:
966 <pre>
967 ./configure --with-modules=mod_tls ...
968 </pre>
969
970 <p>
971 Compiling <code>proftpd</code> requires the following, for FIPS support
972 to work properly:
973 <pre>
974 make CC=<em>/path/to/openssl/bin/</em>fipsld FIPSLD_CC=<em>gcc</em>
975 </pre>
976 The <code>FIPSLD_CC</code> variable should point to your normal C compiler,
977 <i>e.g.</i> <code>gcc</code>. The use of this <code>fipsld</code> program
978 is <b>mandatory</b>. The FIPS standard requires that the linking process
979 happen a very specific way, involving verification of calculated and expected
980 checksums of compiled code, <i>etc</i>. The OpenSSL packages with FIPS
981 support supply this <code>fipsld</code> program which will link the compiled
982 code according to the FIPS specifications. <i>If you do not use
983 <code>fipsld</code>, then attempts to use OpenSSL in FIPS mode will fail.</i>
984 For example, you would see the following if starting a <code>proftpd</code>
985 daemon which has not been linked using <code>fipsld</code> while requesting
986 use of FIPS:
987 <pre>
988 - mod_tls/2.1.2: unable to use FIPS mode: (unknown)
989 - Fatal: unable to load module 'mod_tls.c': Operation not permitted
990 </pre>
991
992 <p>
993 Now, assuming you have compiled and installed your <code>proftpd</code>
994 properly, <i>e.g.</i>:
995 <pre>
996 make CC=<em>/path/to/openssl/bin/</em>fipsld FIPSLD_CC=<em>gcc</em>
997 make CC=<em>/path/to/openssl/bin/</em>fipsld FIPSLD_CC=<em>gcc</em> install
998 </pre>
999 you will now be ready to start <code>proftpd</code>.
1000
1001 <p>
1002 In order for FIPS mode to be effective, OpenSSL must be told to run in FIPS
1003 mode from the very beginning. The <code>mod_tls</code> module initializes the
1004 OpenSSL library when the <code>mod_tls</code> module is loaded, <i>before the
1005 <code>proftpd.conf</code> file is parsed</i>. Thus the requesting of FIPS mode
1006 <b>cannot</b> be done via a setting in <code>proftpd.conf</code>. (Annoying,
1007 I know.)
1008
1009 <p>
1010 Instead, you must use the -D command-line parameter when starting
1011 <code>proftpd</code> (see the docs for the <code>&lt;IfDefine&gt;</code> and
1012 <code>Define</code> directives) to define a specific variable, which the
1013 <code>mod_tls</code> module will look for. Specifically, you will need to
1014 start <code>proftpd</code> like thus:
1015 <pre>
1016 /path/to/proftpd -DTLS_USE_FIPS ...
1017 </pre>
1018 This will define the <code>TLS_USE_FIPS</code> variable; this tells
1019 <code>mod_tls</code> to initialize OpenSSL using FIPS mode. When this works,
1020 you will see the following when <code>proftpd</code> starts up:
1021 <pre>
1022 - mod_tls/2.1.2: FIPS mode enabled
1023 </pre>
1024
1025 <p>
1026 For additional reading on OpenSSL and FIPS, see:
1027 <pre>
1028 <a href="http://www.openssl.org/docs/fips/fipsnotes.html">http://www.openssl.org/docs/fips/fipsnotes.html</a>
1029 </pre>
1030
1031 <p><a name="TLSVersionWarning">
1032 <font color=red>Question</font>: Why do I see the following in my logs when
1033 I start <code>proftpd</code> using <code>mod_tls</code>?
1034 <pre>
1035 - mod_tls/2.2: compiled using OpenSSL version 'OpenSSL 0.9.7i 14 Oct 2005'
1036 headers, but linked to OpenSSL version 'OpenSSL 0.9.7l 28 Sep 2006' library
1037 </pre>
1038 What does this mean?<br>
1039 <font color=blue>Answer</font>: That is an informational/warning message.
1040
1041 <p>
1042 Some systems are badly maintained by their admins (and/or by the packages
1043 installed on the systems), such that the OpenSSL headers can become quite badly
1044 out of sync with the OpenSSL libraries. If this discrepancy becomes bad
1045 enough, you can see strange behavior from OpenSSL, ranging from random behavior
1046 to segfaults. So <code>mod_tls</code> tries to let the admin know about the
1047 system's mismatched OpenSSL header/library versions.
1048
1049 <p>
1050 Usually a minor OpenSSL version difference like the example above is OK,
1051 but it really depends on exactly what changed in OpenSSL, and how.
1052
1053 <p>
1054 If you see the above message, it is not a <i>requirement</i> that you recompile
1055 <code>proftpd</code> against the OpenSSL headers of the same version as the
1056 OpenSSL libraries. However, the version discrepancy <em>is</em> a possible
1057 source of trouble.
1058
1059 <p>
1060 This header/library version check was added recently, hence why older
1061 <code>proftpd</code> releases do not log the warning.
1062
1063 <p><a name="TLSCertificateChainFile">
1064 <font color=red>Question</font>: When should the <a href="../contrib/mod_tls.html#TLSCertificateChainFile"><code>TLSCertificateChainFile</code></a> directive be used?<br>
1065 <font color=blue>Answer</font>: Short answer: only in very specific
1066 arrangements of CA hierarchies. Most of the time, you probably do not need
1067 it.
1068
1069 <p>
1070 The long explanation requires an illustration. Let's say we have a CA hierarchy
1071 that looks something like this:
1072 <pre>
1073 MyRootCA TheirRootCA
1074 | |
1075 MyServerCA TheirClientCA
1076 | |
1077 +------+------+ +------+------+
1078 | | | | | |
1079 certA certB certC cert1 cert2 cert3
1080 </pre>
1081
1082 <p>
1083 Another way of asking the question thus is: "How to I send MyServerCA and
1084 MyRootCA to the client <i>without</i> having them in my trusted CA locations"?
1085
1086 <p>
1087 We might configure <code>mod_tls</code> to have "certA" as the server's
1088 certificate, via <code>TLSRSACertificateFile</code>. The "certA" certificate
1089 is issued by MyServerCA. And let's assume that we do <b>not</b> want to verify
1090 any client certificates issued by MyServerCA.
1091
1092 <p>
1093 We <i>do</i> want to be able to verify client certs issued by a different CA,
1094 say, TheirClientCA. We configure TheirClientCA in <code>mod_tls</code> using
1095 <code>TLSCACertificateFile</code> or <code>TLSCACertificatePath</code>.
1096
1097 <p>
1098 The client connects to <code>mod_tls</code>, and starts the SSL/TLS handshake.
1099 <code>mod_tls</code> sends its "certA" certificate, along with any certs that
1100 may be needed on the client for verifying the server's certificate. (This
1101 is what appears in the "Certificate chain" output from <code>s_client</code>;
1102 see <a href="#TLSDebugging">SSL/TLS debugging</a> above.) Perhaps the client
1103 does not have MyServerCA present in the client certificate store. So we need
1104 to tell <code>mod_tls</code> to send the MyServerCA and MyRootCA certs, along
1105 with "certA". We <i>could</i> place the MyServerCA and MyRootCA certs in
1106 <code>TLSCACertificatePath</code>, but then any client certs issued by
1107 MyServerCA would be trusted as well (and that's not what we want for this
1108 example).
1109
1110 <p>
1111 The solution here is to use <code>TLSCertificateChainFile</code> to supply the
1112 MyServerCA and MyRootCA certs, as part of the server cert chain. The
1113 configured <code>TLSCertificateChainFile</code> would contain the PEM-formatted
1114 MyServerCA and MyRootCA public certs. And although the
1115 <code>TLSCertificateChainFile</code> states that the certs contained in the
1116 file should be in certificate chain order, this is not strictly necessary; the
1117 OpenSSL library will adjust the ordering as appropriate.
1118
1119 <p>
1120 <font color=red>Question</font>: I am having trouble connecting to my
1121 SSL/TLS-enabled <code>proftpd</code>; my FTPS client shows this error:
1122 <pre>
1123 error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure
1124 </pre>
1125 What is wrong?<br>
1126 <font color=blue>Answer</font>: It depends; the first thing is to check
1127 your <code>TLSLog</code> to see what errors, if any, are logged by the
1128 <code>mod_tls</code> module. For example, you might see:
1129 <pre>
1130 Dec 14 10:47:58 mod_tls/2.4.1[13393]: unable to accept TLS connection: protocol error:
1131 (1) error:1408A0C1:SSL routines:SSL3_GET_CLIENT_HELLO:no shared cipher
1132 </pre>
1133 The most common causes of these problems are: <i>a)</i> overly restrictive
1134 <code>TLSCipherSuite</code> configuration, or <i>b)</i> missing server
1135 certificate (<i>i.e.</i> <code>TLSRSACertificateFile</code>,
1136 <code>TLSDSACertificateFile</code>, or <code>TLSPKCS12File</code>). The
1137 file configured for the server certificate might also be badly formatted,
1138 which would result in the same error.
1139
1140 <p>
1141 <font color=red>Question</font>: Is there a way to require TLS (FTPS) for
1142 remote clients <b>only</b>, and allow simple FTP (without TLS) for local
1143 clients (<i>i.e.</i> for clients in networks which we will be able to define
1144 as "local")?<br>
1145 <font color=blue>Answer</font>: Yes.
1146
1147 <p>
1148 To do this, you would use a combination of
1149 <a href="Classes.html"><code>&lt;Class&gt;</code></a> sections and
1150 <a href="../contrib/mod_ifsession.html">mod_ifsession</a>'s
1151 <code>&lt;IfClass&gt;</code>, <i>e.g.</i>:
1152 <pre>
1153 &lt;Class local&gt;
1154 From ...
1155 &lt;/Class&gt;
1156
1157 &lt;IfModule mod_tls.c&gt;
1158 # Normal mod_tls configuration here
1159
1160 &lt;IfClass local&gt;
1161 # Don't require FTPS from local clients
1162 TLSRequired off
1163 &lt;/IfClass&gt;
1164
1165 &lt;IfClass !local&gt;
1166 # Require FTPS from remote/non-local clients
1167 TLSRequired on
1168 &lt;/IfClass&gt;
1169
1170 &lt;/IfModule&gt;
1171 </pre>
1172
1173 <p>
1174 <font color=red>Question</font>: I have configured my <code>proftpd</code>
1175 server for FTPS. When I use FileZilla to try to connect to it, though, I
1176 see one of these errors in the FileZilla logs:
1177 <pre>
1178 GnuTLS error -8: A record packet with illegal version was received
1179 GnuTLS error -9: A TLS packet with unexpected length was received
1180 </pre>
1181 Is there a ProFTPD directive to fix this error?<br>
1182 <font color=blue>Answer</font>: In most cases, the above client error indicates
1183 an <i>error unrelated to SSL/TLS</i> on your server. Check the proftpd
1184 <a href="Debugging.html">debug</a> logging, the
1185 <a href="../contrib/mod_sql.html#SQLLogFile"><code>SQLLogFile</code></a> if
1186 you are using the <code>mod_sql</code> module, <i>etc</i>.
1187
1188 <p><a name="TLSFileZilla">
1189 <font color=red>Question</font>: When I use FileZilla to connect to my
1190 <code>proftpd</code> server, it fails, and I see this error:
1191 <pre>
1192 gnutls_handshake: An unexpected TLS packet was received.
1193 </pre>
1194 How to can I connect to my FTPS server using FileZilla?<br>
1195 <font color=blue>Answer</font>: The most common cause of this is using
1196 a URL such as "ftps://..." in your FileZilla client; for FileZilla, you
1197 <b>must</b> use <b>"ftpes://..."</b> (note the <b><i>e</i></b> there) when
1198 connecting to <code>proftpd</code>. Why? Using "ftpes://..." tells FileZilla
1199 to use <b>explicit</b> TLS, which is what <code>proftpd</code> implements,
1200 as that is the RFC-mandated behavior. See:
1201 <pre>
1202 <a href="https://wiki.filezilla-project.org/SSL/TLS#Explicit_vs_Implicit_FTPS">https://wiki.filezilla-project.org/SSL/TLS#Explicit_vs_Implicit_FTPS</a>
1203 </pre>
1204
1205 <p><a name="TLSLFTP">
1206 <font color=red>Question</font>: I'm trying to use <code>lftp</code> as my
1207 FTPS client for talking to <code>proftpd</code>, configured to use
1208 <code>mod_tls</code>, but it fails to connect. I am using:
1209 <pre>
1210 $ lftp ftps://pc -u myuser
1211 </pre>
1212 What is going wrong?<br>
1213 <font color=blue>Answer</font>: You may need to tell <code>lftp</code> that
1214 using SSL/TLS is <i>allowed</i> when talking to an FTP server:
1215 <pre>
1216 $ lftp pc
1217 lftp&gt; set ftp:ssl-allow yes
1218 lftp&gt; user <i>user</i>
1219 ...
1220 </pre>
1221 <b>or</b> put the above setting in your <code>~/.lftprc</code> file.
1222
1223 <p>
1224 Note that if you <i>always</i> want <code>lftp</code> to use SSL/TLS for FTP
1225 sessions, then you would use this setting:
1226 <pre>
1227 set ftp:ssl-force yes
1228 </pre>
1229
1230 <p><a name="TLSShmcacheVsMemcache">
1231 <font color=red>Question</font>: What is the difference between the
1232 <code>mod_tls_shmcache</code> and <code>mod_tls_memcache</code> modules?<br>
1233 <font color=blue>Answer</font>: Both of these modules are used to support
1234 session caching/resumption in <code>mod_tls</code>. The difference between
1235 these modules is in where the SSL session data is cached/stored.
1236
1237 <p>
1238 The <a href="../contrib/mod_tls_shmcache.html"><code>mod_tls_shmcache</code></a> module stores SSL session data in a SysV shared memory ("shm") segment,
1239 which can be accessed by the different proftpd processes <b>on the same
1240 machine</b>. The <a href="../contrib/mod_tls_memcache.html"><code>mod_tls_memcache</code></a> module stores SSL session data in a memcached server (configured
1241 using the <a href="../modules/mod_memcache.html"><code>mod_memcache</code></a>
1242 module); this allows different proftpd processes <b>on different machines</b>
1243 to access/reuse the cached session data; this can be quite useful when operating
1244 a pool of <code>proftpd</code> servers <i>e.g.</i> behind a load balancer.
1245
1246 <p><a name="TLSKeyNoCert">
1247 <font color=red>Question</font>: When I try to connect using FTPS to my
1248 <code>proftpd</code> server, the SSL/TLS connection fails, and I see the
1249 following errors in the TLSLog:
1250 <pre>
1251 Jul 23 01:15:46 mod_tls/2.4.3[10481]: using default OpenSSL verification locations (see $SSL_CERT_DIR environment variable)
1252 Jul 23 01:15:46 mod_tls/2.4.3[10481]: error checking key from
1253 TLSRSACertificateKeyFile '/usr/local/etc/proftpd/ssl/proftpd.key.pem':
1254 <b>(1) error:140A80B1:SSL routines:SSL_CTX_check_private_key:no certificate assigned</b>
1255 Jul 23 01:15:46 mod_tls/2.4.3[10481]: error initializing OpenSSL context for this session
1256 Jul 23 01:15:46 mod_tls/2.4.3[10481]: TLS/TLS-C requested, starting TLS handshake
1257 Jul 23 01:15:47 mod_tls/2.4.3[10481]: unable to accept TLS connection: protocol error:
1258 (1) error:1408A0C1:SSL routines:SSL3_GET_CLIENT_HELLO:no shared cipher
1259 Jul 23 01:15:47 mod_tls/2.4.3[10481]: TLS/TLS-C negotiation failed on control channel
1260 </pre>
1261 What does this mean?<br>
1262 <font color=blue>Answer</font>: This error means that, somehow, you have
1263 configured a key for a certificate, but do not have the matching certificate
1264 configured. For example, if you configured <code>mod_tls</code> like so:
1265 <pre>
1266 #TLSRSACertificateFile /usr/local/etc/proftpd/ssl/server.cert.pem
1267 TLSRSACertificateKeyFile /usr/local/etc/proftpd/ssl/proftpd.key.pem
1268 </pre>
1269 then you would see the above error.
1270
1271 <p>
1272 This could also happen if, for some reason, the certificate and key in the
1273 configured files were not properly matched up.
1274
1275 <p>
1276 <hr>
1277 <font size=2><b><i>
1278 &copy; Copyright 2017-2019 The ProFTPD Project<br>
1279 All Rights Reserved<br>
1280 </i></b></font>
1281 <hr>
1282
1283 </body>
1284 </html>