source: mod_gnutls/doc/mod_gnutls_manual.mdwn

mod_gnutls/0.9.1
Last change on this file was f064d74, checked in by Fiona Klute <fiona.klute@…>, 2 weeks ago

Handbook: Add a section about module dependencies on socache

  • Property mode set to 100644
File size: 32.3 KB
Line 
1* * * * *
2
3`mod_gnutls` is a module for the Apache web server that provides HTTPS
4(HTTP over Transport Layer Security (TLS)) using the GnuTLS library.
5More information about the module can be found at
6[the project's website](https://mod.gnutls.org/).
7
8* * * * *
9
10Compilation & Installation
11==========================
12
13`mod_gnutls` uses the `./configure && make && make install` mechanism
14common to many Open Source programs.  Most of the dirty work is
15handled by either `./configure` or Apache's `apxs` utility. If you have
16built Apache modules before, there shouldn't be any surprises for you.
17
18The interesting options you can pass to configure are:
19
20`--with-apxs=PATH`
21:   This option is used to specify the location of the apxs utility that
22    was installed as part of apache. Specify the location of the
23    binary, not the directory it is located in.
24
25`--with-apu-config=PATH`
26:   Path to APR Utility Library config tool (`apu-1-config`)
27
28`--help`
29:   Provides a list of all available configure options.
30
31It is recommended to run `make check` before installation. If your
32system doesn't have a loopback device with IPv6 and IPv4 support or
33`localhost` does not resolve to at least one of `[::1]` and
34`127.0.0.1`, you may have to set the `TEST_HOST` or `TEST_IP`
35environment variables when running `./configure` to make the test
36suite work correctly.
37
38* * * * *
39
40Integration
41===========
42
43To activate `mod_gnutls` just add the following line to your httpd.conf
44and restart Apache:
45
46    LoadModule gnutls_module modules/mod_gnutls.so
47
48Module Dependencies
49-------------------
50
51`mod_gnutls` uses the Apache HTTPD [Shared Object
52Cache](http://httpd.apache.org/docs/current/en/socache.html) to cache
53[OCSP responses for OCSP stapling](#gnutlsocspcache) and [TLS
54sessions](#gnutlscache). To use either cache you need to load a
55suitable `mod_socache_PROVIDER` module, which should be provided by
56your Apache installation.
57
58It is recommended to load at least `mod_socache_shmcb`. If that module
59is loaded `mod_gnutls` will [enable OCSP stapling by
60default](#gnutlsocspstapling), without needing any further
61configuration other than a [certificate chain](#gnutlscertificatefile)
62with OCSP support.
63
64Note on HTTP/2
65--------------
66
67HTTP/2 is supported with `mod_gnutls`. However, full support requires
68compiling with GnuTLS 3.6.3 or later. When using lower versions all
69virtual hosts using `mod_gnutls` with overlapping IP/port combinations
70need to use identical `Protocols` directives for protocol negotiation
71to work correctly.
72
73The technical reason is that using HTTP/2 requires ALPN (Application
74Layer Protocol Negotiation) to be set up before GnuTLS parses the TLS
75ClientHello message, but earlier hooks cannot use
76`gnutls_server_name_get()` to retrieve SNI (Server Name Indication)
77data for virtual host selection. Because of this `mod_gnutls` provides
78its own early SNI parser, which requires the `gnutls_ext_raw_parse()`
79function introduced in GnuTLS 3.6.3 to retrieve the extension data in
80a *pre* client hello hook.
81
82During build `./configure` will report "Early SNI: yes" if your
83version of GnuTLS is new enough.
84
85* * * * *
86
87Configuration Directives
88========================
89
90General Options
91---------------
92
93### GnuTLSEnable
94
95Enable GnuTLS for this virtual host
96
97    GnuTLSEnable [on|off]
98
99Default: *off*\
100Context: virtual host
101
102This directive enables SSL/TLS Encryption for a Virtual Host.
103
104### GnuTLSCache
105
106Configure TLS Session Cache
107
108    GnuTLSCache (shmcb|dbm|memcache|...|none)[:PARAMETERS]
109
110Default: `GnuTLSCache none`\
111Context: server config
112
113This directive configures the TLS Session Cache for `mod_gnutls`. This
114could be shared between machines of different architectures. If the
115selected cache implementation is not thread-safe, access is serialized
116using the `gnutls-cache` mutex.
117
118Which cache implementations are available depends on your Apache
119installation and configuration, `mod_gnutls` can use any socache
120provider. In general you will need to load a `mod_socache_PROVIDER`
121module. Common options are described below, please check the Apache
122HTTPD documentation for details on available providers and their
123configuration.
124
125`shmcb`
126:   Uses a shared memory segment. This is a high performance local
127    cache. The parameter is a relative or absolute path to be used if
128    the local shared memory implementation requires one, followed by
129    the cache size in bytes enclosed in parentheses.
130
131    Example: `shmcb:cache/gnutls_cache(65536)`
132
133`dbm`
134:   Uses a DBM cache file. The parameter is a relative or absolute
135    path to be used as the DBM cache file.
136
137    Example: `dbm:cache/gnutls_cache`
138
139`memcache`
140:   Uses memcached server(s) to cache TLS session data. The parameter
141    is a comma separated list of servers (host:port). This can be used
142    to share a session cache between all servers in a cluster.
143
144    Example: `memcache:memcache.example.com:12345,memcache2.example.com:12345`
145
146`none`
147:   Turns off all caching of TLS sessions.
148
149    This can significantly reduce the performance of `mod_gnutls`
150    since even followup connections by a client must renegotiate
151    parameters instead of reusing old ones. This is the default, since
152    it requires no configuration.
153
154    Session tickets are an alternative to using a session cache,
155    please see `GnuTLSSessionTickets`. Note that for TLS 1.3 GnuTLS
156    supports resumption using session tickets only as of version
157    3.6.4.
158
159### GnuTLSCacheTimeout
160
161Timeout for TLS Session Cache expiration
162
163    GnuTLSCacheTimeout SECONDS
164
165Default: `GnuTLSCacheTimeout 300`\
166Context: server config, virtual host
167
168Sets the expiration timeout for cached TLS sessions.
169
170### GnuTLSSessionTickets
171
172Enable Session Tickets for the server
173
174    GnuTLSSessionTickets [on|off]
175
176Default: `on` with GnuTLS 3.6.4 and newer, `off` otherwise\
177Context: server config, virtual host
178
179Session tickets allow TLS session resumption without session state
180stored on the server, using encrypted tickets provided to the clients
181instead. Tickets are an alternative to using a session cache, and
182currently the only session resumption mechanism in TLS 1.3. For a pool
183of servers this option is not recommended since the tickets are bound
184to the issuing server only.
185
186If this option is set in the global configuration, virtual hosts
187without a `GnuTLSSessionTickets` setting will use the global setting.
188
189*Warning:* With GnuTLS version before 3.6.4 the master key that
190protects the tickets is generated only on server start, and there is
191no mechanism to roll over the key. If session tickets are enabled it
192is highly recommended to restart the server regularly to protect past
193sessions in case an attacker gains access to server memory. GnuTLS
1943.6.4 introduced an automatic TOTP-based key rollover, so this warning
195does not apply any more and tickets are enabled by default.
196
197### GnuTLSClientVerify
198
199Enable Client Certificate Verification
200
201    GnuTLSClientVerify [ignore|request|require]
202
203Default: `ignore`\
204Context: server config, virtual host, directory, .htaccess
205
206This directive controls the use of TLS Client Certificate
207Authentication. If used in the .htaccess context, it can force TLS
208re-negotiation.
209
210`ignore`
211:   `mod_gnutls` will ignore the contents of any TLS Client Certificates
212    sent. It will not request that the client sends a certificate.
213
214`request`
215:   The client certificate will be requested, but not required.
216    The Certificate will be validated if sent.  The output of the
217    validation status will be stored in the `SSL_CLIENT_VERIFY`
218    environment variable and can be `SUCCESS`, `FAILED` or `NONE`.
219
220`require`
221:   A Client certificate will be required. Any requests without a valid
222    client certificate will be denied.  The `SSL_CLIENT_VERIFY`
223    environment variable will only be set to `SUCCESS`.
224
225### GnuTLSDHFile
226
227Use the provided PKCS \#3 encoded Diffie-Hellman parameters
228
229    GnuTLSDHFile FILEPATH
230
231Default: *none*\
232Context: server config, virtual host
233
234By default, `mod_gnutls` uses the DH parameters included with GnuTLS
235corresponding to the security level of the configured private keys if
236compiled with GnuTLS 3.5.6 or newer, and the ffdhe2048 DH group as
237defined in RFC 7919, Appendix A.1 otherwise.
238
239If you need to use different DH parameters, you can provide a PEM file
240containing them in PKCS \#3 encoding using this option. Please see the
241"[Parameter
242generation](https://gnutls.org/manual/html_node/Parameter-generation.html)"
243section of the GnuTLS documentation for a short discussion of the
244security implications.
245
246### GnuTLSPriorities
247
248Set the allowed protocol versions, ciphers, key exchange algorithms,
249MACs and compression methods
250
251    GnuTLSPriorities NORMAL:+CIPHER_0:+CIPHER_1:...:+CIPHER_N
252
253Default: `NORMAL`\
254Context: server config, virtual host
255
256Sets the allowed protocol version(s), ciphers, key exchange methods,
257message authentication codes, and other TLS parameters for the server.
258The parameter is a GnuTLS priority string as described in the
259[the GnuTLS documentation](https://gnutls.org/manual/html_node/Priority-Strings.html).
260
261For example, to disable TLS 1.0 use `NORMAL:-VERS-TLS1.0`.
262
263### GnuTLSP11Module
264
265Load this PKCS #11 module.
266
267    GnuTLSP11Module PATH_TO_LIBRARY
268
269Default: *none*\
270Context: server config
271
272Load this PKCS #11 provider module, instead of the system
273defaults. May occur multiple times to load multiple modules.
274
275### GnuTLSPIN
276
277Set the PIN to be used to access encrypted key files or PKCS #11 objects.
278
279    GnuTLSPIN XXXXXX
280
281Default: *none*\
282Context: server config, virtual host
283
284Takes a string to be used as a PIN for the protected objects in
285a security module, or as a key to be used to decrypt PKCS #8, PKCS #12,
286or openssl encrypted keys.
287
288### GnuTLSSRKPIN
289
290Set the SRK PIN to be used to access the TPM.
291
292    GnuTLSSRKPIN XXXXXX
293
294Default: *none*\
295Context: server config, virtual host
296
297Takes a string to be used as a PIN for the protected objects in
298the TPM module.
299
300### GnuTLSExportCertificates
301
302Export the PEM encoded certificates to CGIs
303
304    GnuTLSExportCertificates [off|on|SIZE]
305
306Default: `off`\
307Context: server config, virtual host
308
309This directive configures exporting the full certificates of the
310server and the client to CGI scripts via the `SSL_SERVER_CERT` and
311`SSL_CLIENT_CERT` environment variables. The exported certificates
312will be PEM-encoded, limited to the given size. The type of the
313certificate will be exported in `SSL_SERVER_CERT_TYPE` and
314`SSL_CLIENT_CERT_TYPE`.
315
316SIZE should be an integer number of bytes, or may be written with a
317trailing `K` to indicate kibibytes.  `off` means the same thing as
318`0`, in which case the certificates will not be exported to the
319environment. `on` is an alias for `16K`. If a non-zero size is
320specified for this directive, but a certificate is too large to fit in
321the buffer, then the corresponding environment variable will contain
322the fixed string `GNUTLS_CERTIFICATE_SIZE_LIMIT_EXCEEDED`.
323
324With GnuTLSExportCertificates enabled, `mod_gnutls` exports the same
325environment variables to the CGI process as `mod_ssl`.
326
327X.509 Certificate Authentication
328--------------------------------
329
330### GnuTLSCertificateFile
331
332Set the PEM encoded server certificate or certificate chain
333
334    GnuTLSCertificateFile FILEPATH
335
336Default: *none*\
337Context: server config, virtual host
338
339FILEPATH is an absolute or relative path to a file containing the
340PEM-encoded X.509 certificate to use as this Server's End Entity (EE)
341certificate, and optionally those of the issuing Certificate
342Authorities (CAs). If the file contains multiple certificates they
343must be ordered from EE to the CA closest to the root CA (or the root
344CA itself).
345
346Including at least the immediately issuing CA is highly recommended
347because it is required for OCSP stapling.
348
349Since version 0.7 this can be a PKCS #11 URL instead of a file.
350
351On Linux and other Unix-like systems you can create the file with a
352command like this (assuming "CA 1" issued the server certificate and
353has been issued by "Root CA" itself):
354
355        $ cat server.pem ca-1.pem root-ca.pem >server-chain.pem
356
357### GnuTLSKeyFile
358
359Set to the PEM Encoded Server Private Key
360
361    GnuTLSKeyFile FILEPATH
362
363Default: *none*\
364Context: server config, virtual host
365
366Takes an absolute or relative path to the Server Private Key. Set
367`GnuTLSPIN` if the key file is encrypted.
368
369Since version 0.7 this can be a PKCS #11 URL.
370
371**Security Warning:**\
372This private key must be protected. It is read while Apache is still
373running as root, and does not need to be readable by the nobody or
374apache user.
375
376### GnuTLSClientCAFile
377
378Set the PEM encoded Certificate Authority list to use for X.509 base
379client authentication
380
381    GnuTLSClientCAFile FILEPATH
382
383Default: *none*
384Context: server config, virtual host
385
386Takes an absolute or relative path to a PEM Encoded Certificate to use
387as a Certificate Authority with Client Certificate Authentication.
388This file may contain a list of trusted authorities.
389
390SRP Authentication
391------------------
392
393### GnuTLSSRPPasswdFile
394
395Set to the SRP password file for SRP ciphersuites
396
397    GnuTLSSRPPasswdFile FILEPATH
398
399Default: *none*\
400Context: server config, virtual host
401
402Takes an absolute or relative path to an SRP password file. This is
403the same format as used in libsrp.  You can generate such file using
404the command `srptool --passwd /etc/tpasswd --passwd-conf
405/etc/tpasswd.conf -u test` to set a password for user test.  This
406password file holds the username, a password verifier and the
407dependency to the SRP parameters.
408
409### GnuTLSSRPPasswdConfFile
410
411Set to the SRP password.conf file for SRP ciphersuites
412
413    GnuTLSSRPPasswdConfFile FILEPATH
414
415Default: *none*\
416Context: server config, virtual host
417
418Takes an absolute or relative path to an SRP password.conf file. This
419is the same format as used in `libsrp`.  You can generate such file
420using the command `srptool --create-conf /etc/tpasswd.conf`.  This
421file holds the SRP parameters and is associate with the password file
422(the verifiers depends on these parameters).
423
424TLS Proxy Configuration
425-----------------------
426
427### GnuTLSProxyEngine
428
429Enable TLS proxy connections for this virtual host
430
431    GnuTLSProxyEngine [on|off]
432
433Default: *off*\
434Context: virtual host
435
436This directive enables support for TLS proxy connections for a virtual
437host.
438
439### GnuTLSProxyCAFile
440
441Set to the PEM encoded Certificate Authority Certificate
442
443    GnuTLSProxyCAFile FILEPATH
444
445Default: *none*\
446Context: server config, virtual host
447
448Takes an absolute or relative path to a PEM encoded certificate to use
449as a Certificate Authority when verifying certificates provided by
450proxy back end servers. This file may contain a list of trusted
451authorities. If not set, verification of TLS back end servers will
452always fail due to lack of a trusted CA.
453
454### GnuTLSProxyCRLFile
455
456Set to the PEM encoded Certificate Revocation List
457
458    GnuTLSProxyCRLFile FILEPATH
459
460Default: *none*\
461Context: server config, virtual host
462
463Takes an absolute or relative path to a PEM encoded Certificate
464Revocation List to use when verifying certificates provided by proxy
465back end servers. The file may contain a list of CRLs.
466
467### GnuTLSProxyCertificateFile
468
469Set to the PEM encoded Client Certificate
470
471    GnuTLSProxyCertificateFile FILEPATH
472
473Default: *none*\
474Context: server config, virtual host
475
476Takes an absolute or relative path to a PEM encoded X.509 certificate
477to use as this Server's End Entity (EE) client certificate for TLS
478client authentication in proxy TLS connections. If you need to supply
479certificates for intermediate Certificate Authorities (iCAs), they
480should be listed in sequence in the file, from EE to the iCA closest
481to the root CA. Optionally, you can also include the root CA's
482certificate as the last certificate in the list.
483
484If not set, TLS client authentication will be disabled for TLS proxy
485connections. If set, `GnuTLSProxyKeyFile` must be set as well to
486provide the matching private key.
487
488### GnuTLSProxyKeyFile
489
490Set to the PEM encoded Private Key
491
492    GnuTLSProxyKeyFile FILEPATH
493
494Default: *none*\
495Context: server config, virtual host
496
497Takes an absolute or relative path to the Private Key matching the
498certificate configured using the `GnuTLSProxyCertificateFile`
499directive. This key cannot currently be password protected.
500
501**Security Warning:**\
502This private key must be protected. It is read while Apache is still
503running as root, and does not need to be readable by the nobody or
504apache user.
505
506### GnuTLSProxyPriorities
507
508Set the allowed ciphers, key exchange algorithms, MACs and compression
509methods for proxy connections
510
511    GnuTLSProxyPriorities NORMAL:+CIPHER_0:+CIPHER_1:...:+CIPHER_N
512
513Default: `NORMAL`\
514Context: server config, virtual host
515
516Sets the allowed protocol version(s), ciphers, key exchange methods,
517message authentication codes, and other TLS parameters for TLS proxy
518connections. Like for `GnuTLSPriorities` the parameter is a GnuTLS
519priority string as described in the
520[the GnuTLS documentation](https://gnutls.org/manual/html_node/Priority-Strings.html).
521
522OCSP Stapling Configuration
523---------------------------
524
525### GnuTLSOCSPStapling
526
527Enable OCSP stapling for this (virtual) host.
528
529    GnuTLSOCSPStapling [On|Off]
530
531Default: *on* if requirements are met, *off* otherwise\
532Context: server config, virtual host
533
534OCSP stapling, formally known as the TLS Certificate Status Request
535extension, allows the server to provide the client with a cached OCSP
536response for its certificate during the handshake. With OCSP stapling
537the client does not have to send an OCSP request to the issuer CA to
538check the certificate status, which offers privacy and performance
539advantages, and avoids the security issue of how to handle errors that
540prevent the client from getting a response.
541
542Using OCSP stapling has a few requirements:
543
544* `GnuTLSCertificateFile` must contain the issuer CA certificate in
545  addition to the server certificate so responses can be verified.
546* The server certificate must either contain an OCSP access URI using
547  HTTP, or `GnuTLSOCSPResponseFile` must be set.
548* Caching OCSP responses requires a cache to store responses. If
549  `mod_socache_shmcb` is loaded `mod_gnutls` can set up the cache
550  automatically without additional configuration, see
551  `GnuTLSOCSPCache`.
552
553Stapling is activated by default if these requirements are met. If
554`GnuTLSOCSPStapling` is explicitly set to `on` unmet requirements are
555an error.
556
557OCSP cache updates are serialized using the `gnutls-ocsp` mutex.
558
559### GnuTLSOCSPCache
560
561OCSP stapling cache configuration
562
563        GnuTLSOCSPCache (shmcb|memcache|...|none)[:PARAMETERS]
564
565Default: `shmcb:gnutls_ocsp_cache`\
566Context: server config
567
568This directive configures the OCSP stapling cache, and uses the same
569syntax as `GnuTLSOCSPCache`. Please check there for details.
570
571The default should be reasonable for most servers and requires
572[mod\_socache\_shmcb](http://httpd.apache.org/docs/current/en/mod/mod_socache_shmcb.html)
573to be loaded. Servers with very many virtual hosts may need to
574increase the default cache size via the parameters string, those with
575few virtual hosts and memory constraints could save a few KB by reducing
576it. Note that `mod_socache_dbm` has a size constraint for entries that
577is generally too small for OCSP responses.
578
579If the selected cache implementation is not thread-safe, access
580is serialized using the `gnutls-ocsp-cache` mutex.
581
582### GnuTLSOCSPAutoRefresh
583
584Regularly refresh cached OCSP response independent of TLS handshakes?
585
586    GnuTLSOCSPAutoRefresh [On|Off]
587
588Default: *on*\
589Context: server config, virtual host
590
591By default `mod_gnutls` will regularly refresh the cached OCSP
592response for hosts that have OCSP stapling enabled, regardless of
593whether it is used. This has advantages over updating the OCSP
594response only if a TLS handshake needs it:
595
596* Updating the cached response before it expires can hide short
597  unavailability of the OCSP responder, if a repeated request is
598  successful before the cache expires (see below).
599
600* Handshakes are not slowed down by fetching responses.
601
602The interval to the next request is determined as follows: After a
603successful OCSP request the next one is scheduled for a random period
604between `GnuTLSOCSPFuzzTime` and half of it before
605`GnuTLSOCSPCacheTimeout` expires. For example, if the cache timeout is
6063600 seconds and the fuzz time 600 seconds, the next request will be
607sent after 3000 to 3300 seconds. If the validity period of the
608response expires before then, the selected interval is halved until it
609is smaller than the time until expiry. If an OCSP request fails, it is
610retried after `GnuTLSOCSPFailureTimeout`.
611
612Regularly updating the OCSP cache requires `mod_watchdog`,
613`mod_gnutls` will fall back to updating the OCSP cache during
614handshakes if `mod_watchdog` is not available or this option is set to
615`Off`.
616
617### GnuTLSOCSPCheckNonce
618
619Check the nonce in OCSP responses?
620
621    GnuTLSOCSPCheckNonce [On|Off]
622
623Default: *on*\
624Context: server config, virtual host
625
626Some CAs refuse to send nonces in their OCSP responses, probably
627because that way they can cache responses. If your CA is one of them
628you can use this flag to disable nonce verification. Note that
629`mod_gnutls` will _send_ a nonce either way.
630
631### GnuTLSOCSPResponseFile
632
633Read the OCSP response for stapling from this file instead of sending
634a request over HTTP.
635
636    GnuTLSOCSPResponseFile /path/to/response.der
637
638Default: *empty*\
639Context: server config, virtual host
640
641The response file must be updated externally, for example using a cron
642job. This option is an alternative to the server fetching OCSP
643responses over HTTP. Reasons to use this option include:
644
645* Performing OCSP requests separate from the web server, to prevent slow
646  responses from stalling handshakes.
647* The issuer CA uses an access method other than HTTP.
648* Testing
649
650You can use a GnuTLS `ocsptool` command like the following to create
651and update the response file:
652
653    ocsptool --ask --nonce --load-issuer ca_cert.pem \
654        --load-cert server_cert.pem --outfile ocsp_response.der
655
656Additional error checking is highly recommended. You may have to
657remove the `--nonce` option if the OCSP responder of your CA does not
658support nonces.
659
660### GnuTLSOCSPCacheTimeout
661
662Cache timeout for OCSP responses
663
664    GnuTLSOCSPCacheTimeout SECONDS
665
666Default: *3600*\
667Context: server config, virtual host
668
669Cached OCSP responses will be refreshed after the configured number of
670seconds. How long this timeout should reasonably be depends on your
671CA, namely how often its OCSP responder is updated and how long
672responses are valid. Note that a response will not be cached beyond
673its lifetime as denoted in the `nextUpdate` field of the response.
674
675### GnuTLSOCSPFailureTimeout
676
677Wait this many seconds before retrying a failed OCSP request.
678
679    GnuTLSOCSPFailureTimeout SECONDS
680
681Default: *300*\
682Context: server config, virtual host
683
684Retries of failed OCSP requests must be rate limited to avoid
685overloading both the server using mod_gnutls and the CA's OCSP
686responder. A shorter value increases the load on both sides, a longer
687one means that stapling will remain disabled for longer after a failed
688request.
689
690### GnuTLSOCSPFuzzTime
691
692Update the cached OCSP response up to this time before the cache expires
693
694    GnuTLSOCSPFuzzTime SECONDS
695
696Default: *larger of GnuTLSOCSPCacheTimeout / 8 and GnuTLSOCSPFailureTimeout \* 2*\
697Context: server config, virtual host
698
699Refreshing the cached response before it expires hides short OCSP
700responder unavailability. See `GnuTLSOCSPAutoRefresh` for how this
701value is used, using at least twice `GnuTLSOCSPFailureTimeout` is
702recommended.
703
704### GnuTLSOCSPSocketTimeout
705
706Timeout for TCP sockets used to send OCSP requests
707
708    GnuTLSOCSPFailureTimeout SECONDS
709
710Default: *6*\
711Context: server config, virtual host
712
713Stalled OCSP requests must time out after a while to prevent stalling
714the server too much. However, if the timeout is too short requests may
715fail with a slow OCSP responder or high latency network
716connection. This parameter allows you to adjust the timeout if
717necessary.
718
719Note that this is not an upper limit for the completion of an OCSP
720request but a socket timeout. The connection will time out if there is
721no activity (successful send or receive) at all for the configured
722time.
723
724* * * * *
725
726Configuration Examples
727======================
728
729Minimal Example
730---------------
731
732A minimal server configuration using mod_gnutls might look like this
733(other than the default setup):
734
735     # Load mod_gnutls into Apache.
736     LoadModule gnutls_module modules/mod_gnutls.so
737
738         Listen 192.0.2.1:443
739
740     <VirtualHost _default_:443>
741             # Standard virtual host stuff
742         DocumentRoot /www/site1.example.com/html
743         ServerName site1.example.com:443
744         
745                 # Minimal mod_gnutls setup: enable, and set credentials
746                 GnuTLSEnable on
747         GnuTLSCertificateFile conf/tls/site1_cert_chain.pem
748         GnuTLSKeyFile conf/tls/site1_key.pem
749     </VirtualHost>
750
751This gives you an HTTPS site using the GnuTLS `NORMAL` set of
752ciphersuites. OCSP stapling will be enabled if the server certificate
753contains an OCSP URI, `conf/tls/site1_cert_chain.pem` contains the
754issuer certificate in addition to the server's, and
755[mod\_socache\_shmcb](http://httpd.apache.org/docs/current/en/mod/mod_socache_shmcb.html)
756is loaded. With Gnutls 3.6.4 or newer session tickets are enabled,
757too.
758
759Virtual Hosts with Server Name Indication
760-----------------------------------------
761
762`mod_gnutls` supports Server Name Indication (SNI), as specified in
763[RFC 6066, Section 3](https://tools.ietf.org/html/rfc6066#section-3).
764This allows hosting many TLS websites with a single IP address, you
765can just add virtual host configurations. All recent browsers support
766this standard. Here is an example using SNI:
767
768     # Load the module into Apache.
769     LoadModule gnutls_module modules/mod_gnutls.so
770         # This example server uses session tickets, no cache.
771     GnuTLSSessionTickets on
772
773     # SNI allows hosting multiple sites using one IP address. This
774     # could also be 'Listen *:443', just like '*:80' is common for
775     # non-HTTPS
776     Listen 198.51.100.1:443
777
778     <VirtualHost _default_:443>
779         GnuTLSEnable on
780         DocumentRoot /www/site1.example.com/html
781         ServerName site1.example.com:443
782         GnuTLSCertificateFile conf/tls/site1.crt
783         GnuTLSKeyFile conf/tls/site1.key
784     </VirtualHost>
785
786     <VirtualHost _default_:443>
787         GnuTLSEnable on
788         DocumentRoot /www/site2.example.com/html
789         ServerName site2.example.com:443
790         GnuTLSCertificateFile conf/tls/site2.crt
791         GnuTLSKeyFile conf/tls/site2.key
792     </VirtualHost>
793
794     <VirtualHost _default_:443>
795         GnuTLSEnable on
796         DocumentRoot /www/site3.example.com/html
797         ServerName site3.example.com:443
798         GnuTLSCertificateFile conf/tls/site3.crt
799         GnuTLSKeyFile conf/tls/site3.key
800         # Enable HTTP/2. With GnuTLS before version 3.6.3 all
801         # virtual hosts in this example would have to share this
802         # directive to work correctly.
803         Protocols h2 http/1.1
804     </VirtualHost>
805
806Virtual Hosts without SNI
807-------------------------
808
809If you need to support clients that do not use SNI, you have to use a
810unique IP address/port combination for each virtual host. In this
811example all virtual hosts use the default port for HTTPS (443) and
812different IP addresses.
813
814     # Load the module into Apache.
815     LoadModule gnutls_module modules/mod_gnutls.so
816         # This example server uses a session cache.
817     GnuTLSCache dbm:/var/cache/www-tls-cache
818     GnuTLSCacheTimeout 1200
819
820     # Without SNI you need one IP Address per site. The IP addresses
821         # are listed separately for clarity, you could also use "Listen 443"
822         # to use that port on all available IP addresses.
823     Listen 192.0.2.1:443
824     Listen 192.0.2.2:443
825     Listen 192.0.2.3:443
826
827     <VirtualHost 192.0.2.1:443>
828         GnuTLSEnable on
829         GnuTLSPriorities SECURE128
830         DocumentRoot /www/site1.example.com/html
831         ServerName site1.example.com:443
832         GnuTLSCertificateFile conf/tls/site1.crt
833         GnuTLSKeyFile conf/tls/site1.key
834     </VirtualHost>
835
836     <VirtualHost 192.0.2.2:443>
837         # This virtual host enables SRP authentication
838         GnuTLSEnable on
839         GnuTLSPriorities NORMAL:+SRP
840         DocumentRoot /www/site2.example.com/html
841         ServerName site2.example.com:443
842         GnuTLSSRPPasswdFile conf/tls/tpasswd.site2
843         GnuTLSSRPPasswdConfFile conf/tls/tpasswd.site2.conf
844     </VirtualHost>
845
846     <VirtualHost 192.0.2.3:443>
847         # This server enables SRP and X.509 authentication.
848         GnuTLSEnable on
849         GnuTLSPriorities NORMAL:+SRP:+SRP-RSA:+SRP-DSS
850         DocumentRoot /www/site3.example.com/html
851         ServerName site3.example.com:443
852         GnuTLSCertificateFile conf/tls/site3.crt
853         GnuTLSKeyFile conf/tls/site3.key
854         GnuTLSClientVerify ignore
855         GnuTLSSRPPasswdFile conf/tls/tpasswd.site3
856         GnuTLSSRPPasswdConfFile conf/tls/tpasswd.site3.conf
857     </VirtualHost>
858
859OCSP Stapling Example
860---------------------
861
862This is an example with a customized OCSP stapling configuration. What
863is a resonable cache timeout varies depending on how long your CA's
864OCSP responses are valid. Some CAs provide responses that are valid
865for multiple days, in that case timeout and fuzz time could be
866significantly larger.
867
868     # Load the module into Apache.
869     LoadModule gnutls_module modules/mod_gnutls.so
870         # A 64K cache is more than enough for one response
871     GnuTLSOCSPCache shmcb:ocsp_cache(65536)
872
873     Listen 192.0.2.1:443
874
875     <VirtualHost _default_:443>
876         GnuTLSEnable           On
877         DocumentRoot           /www/site1.example.com/html
878         ServerName             site1.example.com:443
879         GnuTLSCertificateFile  conf/tls/site1_cert_chain.pem
880         GnuTLSKeyFile          conf/tls/site1_key.pem
881         GnuTLSOCSPStapling     On
882                 # The cached OCSP response is kept for up to 4 hours,
883                 # with updates scheduled every 3 to 3.5 hours.
884         GnuTLSOCSPCacheTimeout 21600
885                 GnuTLSOCSPFuzzTime     3600
886     </VirtualHost>
887
888* * * * *
889
890Environment Variables
891=====================
892
893`mod_gnutls` exports the following environment variables to scripts.
894These are compatible with `mod_ssl`.
895
896`HTTPS`
897-------
898
899Can be `on` or `off`
900
901`SSL_VERSION_LIBRARY`
902---------------------
903
904The version of the GnuTLS library
905
906`SSL_VERSION_INTERFACE`
907-----------------------
908
909The version of this module
910
911`SSL_PROTOCOL`
912--------------
913
914The SSL or TLS protocol name (such as `TLS 1.0` etc.)
915
916`SSL_CIPHER`
917------------
918
919The SSL or TLS cipher suite name
920
921`SSL_COMPRESS_METHOD`
922---------------------
923
924The negotiated compression method (`NULL` or `DEFLATE`)
925
926`SSL_SRP_USER`
927--------------
928
929The SRP username used for authentication (only set when
930`GnuTLSSRPPasswdFile` and `GnuTLSSRPPasswdConfFile` are configured).
931
932`SSL_CIPHER_USEKEYSIZE` & `SSL_CIPHER_ALGKEYSIZE`
933-------------------------------------------------
934
935The number if bits used in the used cipher algorithm.
936
937This does not fully reflect the security level since the size of
938RSA or DHE key exchange parameters affect the security level too.
939
940`SSL_DH_PRIME_BITS`
941-------------------
942
943The number if bits in the modulus for the DH group, if DHE or static
944DH is used.
945
946This will not be set if DH is not used.
947
948`SSL_CIPHER_EXPORT`
949-------------------
950
951`True` or `False`. Whether the cipher suite negotiated is an export one.
952
953`SSL_SESSION_ID`
954----------------
955
956The session ID negotiated in this session. Can be the same during client
957reloads.
958
959`SSL_CLIENT_V_REMAIN`
960---------------------
961
962The number of days until the client's certificate is expired.
963
964`SSL_CLIENT_V_START`
965--------------------
966
967The activation time of client's certificate.
968
969`SSL_CLIENT_V_END`
970------------------
971
972The expiration time of client's certificate.
973
974`SSL_CLIENT_S_DN`
975-----------------
976
977The distinguished name of client's certificate in RFC2253 format.
978
979`SSL_CLIENT_I_DN`
980-----------------
981
982The distinguished name of the issuer of the client's certificate in
983RFC2253 format.
984
985`SSL_CLIENT_S_AN%`
986------------------
987
988These will contain the alternative names of the client certificate (`%` is
989a number starting from zero).
990
991The values will be prepended by `DNSNAME:`, `RFC822NAME:` or `URI:`
992depending on the type.
993
994If it is not supported the value `UNSUPPORTED` will be set.
995
996`SSL_SERVER_M_SERIAL`
997---------------------
998
999The serial number of the server's certificate.
1000
1001`SSL_SERVER_M_VERSION`
1002----------------------
1003
1004The version of the server's certificate.
1005
1006`SSL_SERVER_A_SIG`
1007------------------
1008
1009The algorithm used for the signature in server's certificate.
1010
1011`SSL_SERVER_A_KEY`
1012------------------
1013
1014The public key algorithm in server's certificate.
1015
1016`SSL_SERVER_CERT`
1017------------------
1018
1019The PEM-encoded (X.509) server certificate (see the
1020`GnuTLSExportCertificates` directive).
1021
1022`SSL_SERVER_CERT_TYPE`
1023----------------------
1024
1025The certificate type will be `X.509`.
1026
1027`SSL_CLIENT_CERT`
1028------------------
1029
1030PEM-encoded (X.509) client certificate, if any (see the
1031`GnuTLSExportCertificates` directive).
1032
1033`SSL_CLIENT_CERT_TYPE`
1034----------------------
1035
1036The certificate type will be `X.509`, if any.
Note: See TracBrowser for help on using the repository browser.