source: mod_gnutls/docs/mod_gnutls_manual.mdwn @ 999cdec

Last change on this file since 999cdec was 999cdec, checked in by Daniel Kahn Gillmor <dkg@…>, 7 years ago

GnuTLSExportCertificates should control maximum size of exported certs

The server administrator should be able to control the maximum size of
the exported certificate environment variables. This will be done via
the existing GnuTLSExportCertificates environment variable.

This patch adds documentation of intended new feature and a test for
support. The test currently fails because the feature is not

  • Property mode set to 100644
File size: 20.8 KB
[e7527b9]1% `mod_gnutls` Manual
3* * * * *
[bce7907]5`mod_gnutls` is a module for the Apache web server that provides HTTPS
6(HTTP over Transport Layer Security (TLS) or the older Secure Sockets
7Layer (SSL)) using the GnuTLS library.  More information about the
8module can be found at [the project's website](
10* * * * *
12Compilation & Installation
[e7527b9]15`mod_gnutls` uses the `./configure && make && make install` mechanism
16common to many Open Source programs.  Most of the dirty work is
17handled by either `./configure` or Apache's `apxs` utility. If you have
18built Apache modules before, there shouldn't be any surprises for you.
20The interesting options you can pass to configure are:
23:   This option is used to specify the location of the apxs utility that
24    was installed as part of apache. Specify the location of the
25    binary, not the directory it is located in.
28:   Full path to the libgnutls-config program.
31:   Prefix to where apr\_memcache is installed.
34:   Provides a list of all available configure options.
36* * * * *
[2b16350]41To activate `mod_gnutls` just add the following line to your httpd.conf
[4ee45a1]42and restart Apache:
[2b16350]44    LoadModule gnutls_module modules/
46* * * * *
[2b16350]48Configuration Directives
[2b16350]54Enable GnuTLS for this virtual host
[2b16350]56    GnuTLSEnable [on|off]
[2b16350]58Default: *off*\
59Context: virtual host
[2b16350]61This directive enables SSL/TLS Encryption for a Virtual Host.
[2b16350]66Configure SSL Session Cache
[2b16350]68    GnuTLSCache [dbm|gdbm|memcache|none] [PATH|SERVERLIST|-]
[2b16350]70Default: `GnuTLSCache none`\
71Context: server config
[2b16350]73This directive configures the SSL Session Cache for `mod_gnutls`.
74This could be shared between machines of different architectures.
[2b16350]76`dbm` (Requires Berkeley DBM)
77:   Uses the default Berkeley DB backend of APR DBM to cache SSL
78    Sessions results.  The argument is a relative or absolute path to
79    be used as the DBM Cache file. This is compatible with most
80    operating systems, but needs the Apache Runtime to be compiled
81    with Berkeley DBM support.
84:   Uses the GDBM backend of APR DBM to cache SSL Sessions results.
[2b16350]86    The argument is a relative or absolute path to be used as the DBM Cache
87    file.  This is the recommended option.
90:   Uses a memcached server to cache the SSL Session.
[2b16350]92    The argument is a space separated list of servers. If no port
93    number is supplied, the default of 11211 is used.  This can be
94    used to share a session cache between all servers in a cluster.
97:   Turns off all caching of SSL Sessions.
[2b16350]99    This can significantly reduce the performance of `mod_gnutls` since
100    even followup connections by a client must renegotiate parameters
101    instead of reusing old ones.  This is the default, since it
102    requires no configuration.
[2b16350]107Timeout for SSL Session Cache expiration
[2b16350]109    GnuTLSCacheTimeout SECONDS
[2b16350]111Default: `GnuTLSCacheTimeout 300`\
112Context: server config
[2b16350]114Sets the timeout for SSL Session Cache entries expiration.  This
115directive is valid even if Session Tickets are used, and indicates the
116expiration time of the ticket in seconds.
[2b16350]121Enable Session Tickets for the server
[2b16350]123    GnuTLSSessionTickets [on|off]
[2b16350]125Default: `off`\
126Context: server config, virtual host
128To avoid storing data for TLS session resumption it is allowed to
[2b16350]129provide client with a ticket, to use on return.  Use for servers with
130limited storage, and don't combine with GnuTLSCache. For a pool of
131servers this option is not recommended since the tickets are unique
132for the issuing server only.
[2b16350]138Set to the PEM Encoded Server Certificate
[2b16350]140    GnuTLSCertificateFile FILEPATH
[2b16350]142Default: *none*\
143Context: server config, virtual host
145Takes an absolute or relative path to a PEM-encoded X.509 certificate to
146use as this Server's End Entity (EE) certificate. If you need to supply
147certificates for intermediate Certificate Authorities (iCAs), they
148should be listed in sequence in the file, from EE to the iCA closest to
149the root CA. Optionally, you can also include the root CA's certificate
150as the last certificate in the list.
[2b16350]155Set to the PEM Encoded Server Certificate
[2b16350]157    GnuTLSCertificateFile FILEPATH
[2b16350]159Default: *none*\
160Context: server config, virtual host
[2b16350]162Takes an absolute or relative path to the Server Private Key.  This
163key cannot currently be password protected.
165**Security Warning:**\
166 This private key must be protected. It is read while Apache is still
167running as root, and does not need to be readable by the nobody or
168apache user.
[2b16350]173Set to a base64 Encoded Server OpenPGP Certificate
[2b16350]175    GnuTLSPGPCertificateFile FILEPATH
[2b16350]177Default: *none*\
178Context: server config, virtual host
180Takes an absolute or relative path to a base64 Encoded OpenPGP
181Certificate to use as this Server's Certificate.
[2b16350]186Set to the Server OpenPGP Secret Key
[2b16350]188    GnuTLSPGPKeyFile FILEPATH
[2b16350]190Default: *none*\
191Context: server config, virtual host
193Takes an absolute or relative path to the Server Private Key. This key
194cannot currently be password protected.
196**Security Warning:**\
197 This private key must be protected. It is read while Apache is still
198running as root, and does not need to be readable by the nobody or
199apache user.
204Enable Client Certificate Verification\
[2b16350]206    GnuTLSClientVerify [ignore|request|require]
[2b16350]208Default: `ignore`\
209Context: server config, virtual host, directory, .htaccess
211This directive controls the use of SSL Client Certificate
[2b16350]212Authentication. If used in the .htaccess context, it can force TLS
216:   `mod_gnutls` will ignore the contents of any SSL Client Certificates
217    sent. It will not request that the client sends a certificate.
220:   The client certificate will be requested, but not required.
221    The Certificate will be validated if sent.  The output of the
222    validation status will be stored in the `SSL_CLIENT_VERIFY`
223    environment variable and can be `SUCCESS`, `FAILED` or `NONE`.
226:   A Client certificate will be required. Any requests without a valid
227    client certificate will be denied.  The `SSL_CLIENT_VERIFY`
228    environment variable will only be set to `SUCCESS`.
[2b16350]233Set to the PEM Encoded Certificate Authority Certificate
[2b16350]235    GnuTLSClientCAFile FILEPATH
[2b16350]237Default: *none*
238Context: server config, virtual host
240Takes an absolute or relative path to a PEM Encoded Certificate to use
[2b16350]241as a Certificate Authority with Client Certificate Authentication.
242This file may contain a list of trusted authorities.
[2b16350]247Set to a base64 Encoded key ring
[2b16350]249    GnuTLSPGPKeyringFile FILEPATH
[2b16350]251Default: *none*\
252Context: server config, virtual host
[2b16350]254Takes an absolute or relative path to a base64 Encoded Certificate
255list (key ring) to use as a means of verification of Client
256Certificates.  This file should contain a list of trusted signers.
[2b16350]261Set to the PKCS \#3 encoded Diffie Hellman parameters
[2b16350]263    GnuTLSDHFile FILEPATH
[2b16350]265Default: *none*\
266Context: server config, virtual host
[2b16350]268Takes an absolute or relative path to a PKCS \#3 encoded DH
269parameters.Those are used when the DHE key exchange method is enabled.
270You can generate this file using `certtool --generate-dh-params --bits
2712048`.  If not set `mod_gnutls` will use the included parameters.
[2b16350]276Set to the SRP password file for SRP ciphersuites
[2b16350]278    GnuTLSSRPPasswdFile FILEPATH
[2b16350]280Default: *none*\
281Context: server config, virtual host
[2b16350]283Takes an absolute or relative path to an SRP password file. This is
284the same format as used in libsrp.  You can generate such file using
285the command `srptool --passwd /etc/tpasswd --passwd-conf
286/etc/tpasswd.conf -u test` to set a password for user test.  This
287password file holds the username, a password verifier and the
288dependency to the SRP parameters.
[2b16350]293Set to the SRP password.conf file for SRP ciphersuites
[2b16350]295    GnuTLSSRPPasswdConfFile FILEPATH
[2b16350]297Default: *none*\
298Context: server config, virtual host
[2b16350]300Takes an absolute or relative path to an SRP password.conf file. This
301is the same format as used in `libsrp`.  You can generate such file
302using the command `srptool --create-conf /etc/tpasswd.conf`.  This
303file holds the SRP parameters and is associate with the password file
304(the verifiers depends on these parameters).
[2b16350]309Set the allowed ciphers, key exchange algorithms, MACs and compression
[5409165]312    GnuTLSPriorities NORMAL:+CIPHER_0:+CIPHER_1:...:+CIPHER_N
[2b16350]314Default: *none*\
315Context: server config, virtual host
[2b16350]317Takes a semi-colon separated list of ciphers, key exchange methods
318Message authentication codes and compression methods to enable.
319The allowed keywords are specified in the `gnutls_priority_init()`
320function of GnuTLS.
[5409165]322Full details can be found at [the GnuTLS documentation](
[2b16350]323In brief you can specify a set of ciphersuites from the choices:
326:   The empty list.
329:   A list with all the supported cipher combinations
330    including the `EXPORT` strength algorithms.
333:   A list with all the secure cipher combinations sorted in terms of performance.
336:   A list with all the secure cipher combinations sorted
337    with respect to security margin (subjective term).
340:   A list with all the secure cipher combinations including
341    the 256-bit ciphers sorted with respect to security margin.
[2b16350]343Additionally you can add or remove algorithms using the `+` and `!`
344prefixes respectively.
[2b16350]346For example, in order to disable the `ARCFOUR` cipher from the `NORMAL` set
347you can use the string `NORMAL:!ARCFOUR-128`
[2b16350]349Other options such as the protocol version and the compression method
350can be specified using the `VERS-` and `COMP-` prefixes.
[2b16350]352So in order to remove or add a specific TLS version from the `NORMAL`
353set, use `NORMAL:!VERS-SSL3.0`.  And to enable zlib compression use
[2b16350]357However it is recommended not to add compression at this level.  With
358the `NONE` set, in order to be usable, you have to specify a complete
359set of combinations of protocol versions, cipher algorithms
360(`AES-128-CBC`), key exchange algorithms (`RSA`), message
361authentication codes (`SHA1`) and compression methods (`COMP-NULL`).
[2b16350]363You can find a list of all supported Ciphers, Versions, MACs, etc.  by
364running `gnutls-cli --list`.
[2b16350]366The special keyword `%COMPAT` will disable some security features such
[4ee45a1]367as protection against statistical attacks to ciphertext data in order to
368achieve maximum compatibility (some broken mobile clients need this).
[2b16350]373Export the PEM encoded certificates to CGIs
[999cdec]375    GnuTLSExportCertificates [off|on|SIZE]
[2b16350]377Default: `off`\
378Context: server config, virtual host
[999cdec]380This directive configures exporting the full certificates of the
381server and the client to CGI scripts via the `SSL_SERVER_CERT` and
382`SSL_CLIENT_CERT` environment variables. The exported certificates
383will be PEM-encoded (if X.509) or ASCII-armored (if OpenPGP) up to the
384size given.  The type of the certificate will be exported in
387SIZE should be an integer number of bytes, or may be written with a
388trailing `K` to indicate kibibytes.  `off` means the same thing as
389`0`, in which case the certificates will not be exported to the
390environment.  `on` is an alias for `16K`.  If a non-zero size is
391specified for this directive, but a certificate is too large to fit in
392the buffer, then the corresponding environment variable will contain
[2b16350]395With GnuTLSExportCertificates enabled, `mod_gnutls` exports the same
396environment variables to the CGI process as `mod_ssl`.
398* * * * *
400Configuration Examples
[2b16350]403Simple Standard SSL Example
406The following is an example of standard SSL Hosting, using one IP
407Addresses for each virtual host
[2b16350]409     # Load the module into Apache.
410     LoadModule gnutls_module modules/
411     GnuTLSCache gdbm /var/cache/www-tls-cache
412     GnuTLSCacheTimeout 500
413     # With normal SSL Websites, you need one IP Address per-site.
414     Listen
415     Listen
416     Listen
417     Listen
418     <VirtualHost>
419     GnuTLSEnable on
421     DocumentRoot /www/
422     ServerName
423     GnuTLSCertificateFile conf/ssl/site1.crt
424     GnuTLSKeyFile conf/ss/site1.key
425     </VirtualHost>
426     <VirtualHost>
427     # This virtual host enables SRP authentication
428     GnuTLSEnable on
429     GnuTLSPriorities NORMAL:+SRP
430     DocumentRoot /www/
431     ServerName
432     GnuTLSSRPPasswdFile conf/ssl/tpasswd.site2
433     GnuTLSSRPPasswdConfFile conf/ssl/tpasswd.site2.conf
434     </VirtualHost>
435     <VirtualHost>
436     # This server enables SRP, OpenPGP and X.509 authentication.
437     GnuTLSEnable on
438     GnuTLSPriorities NORMAL:+SRP:+SRP-RSA:+SRP-DSS
439     DocumentRoot /www/
440     ServerName
441     GnuTLSCertificateFile conf/ssl/site3.crt
442     GnuTLSKeyFile conf/ss/site3.key
443     GnuTLSClientVerify ignore
444     GnuTLSPGPCertificateFile conf/ss/
445     GnuTLSPGPKeyFile conf/ss/site3.sec.asc
446     GnuTLSSRPPasswdFile conf/ssl/tpasswd.site3
447     GnuTLSSRPPasswdConfFile conf/ssl/tpasswd.site3.conf
448     </VirtualHost>
449     <VirtualHost>
450     GnuTLSEnable on
451     # %COMPAT disables some security features to enable maximum compatibility with clients.
452     GnuTLSPriorities NONE:+AES-128-CBC:+ARCFOUR-128:+RSA:+SHA1:+MD5:+COMP-NULL:%COMPAT
453     DocumentRoot /www/
454     ServerName
455     GnuTLSCertificateFile conf/ssl/site4.crt
456     GnuTLSKeyFile conf/ss/site4.key
457     </VirtualHost>
459Server Name Indication Example
462`mod_gnutls` can also use "Server Name Indication", as specified in
463RFC 3546.  This allows hosting many SSL Websites, with a Single IP
464Address.  Currently all the recent browsers support this
465standard. Here is an example, using SNI: ` `
468     # Load the module into Apache.
469     LoadModule gnutls_module modules/
470     # With normal SSL Websites, you need one IP Address per-site.
471     Listen
472     # This could also be 'Listen *:443',
473     # just like '*:80' is common for non-https
474     # No caching. Enable session tickets. Timeout is still used for
475     # ticket expiration.
476     GnuTLSCacheTimeout 600
477     # This tells apache, that for this IP/Port combination, we want to use
478     # Name Based Virtual Hosting. In the case of Server Name Indication,
479     # it lets mod_gnutls pick the correct Server Certificate.
480     NameVirtualHost
481     <VirtualHost>
482     GnuTLSEnable on
483     GnuTLSSessionTickets on
484     GnuTLSPriorities NORMAL
485     DocumentRoot /www/
486     ServerName
487     GnuTLSCertificateFile conf/ssl/site1.crt
488     GnuTLSKeyFile conf/ss/site1.key
489     </VirtualHost>
490     <VirtualHost>
491     GnuTLSEnable on
492     GnuTLSPriorities NORMAL
493     DocumentRoot /www/
494     ServerName
495     GnuTLSCertificateFile conf/ssl/site2.crt
496     GnuTLSKeyFile conf/ss/site2.key
497     </VirtualHost>
498     <VirtualHost>
499     GnuTLSEnable on
500     GnuTLSPriorities NORMAL
501     DocumentRoot /www/
502     ServerName
503     GnuTLSCertificateFile conf/ssl/site3.crt
504     GnuTLSKeyFile conf/ss/site3.key
505     </VirtualHost>
506     <VirtualHost>
507     GnuTLSEnable on
508     GnuTLSPriorities NORMAL
509     DocumentRoot /www/
510     ServerName
511     GnuTLSCertificateFile conf/ssl/site4.crt
512     GnuTLSKeyFile conf/ss/site4.key
513     </VirtualHost>
[2b16350]516* * * * *
[2b16350]518Performance Issues
521`mod_gnutls` by default uses conservative settings for the server.
522You can fine tune the configuration to reduce the load on a busy
523server.  The following examples do exactly this:
526     # Load the module into Apache.
527     LoadModule gnutls_module modules/
528     # Using 4 memcache servers to distribute the SSL Session Cache.
529     GnuTLSCache memcache ""
530     GnuTLSCacheTimeout 600
531     Listen
532     NameVirtualHost
533     <VirtualHost>
534     GnuTLSEnable on
535     # Here we disable the Perfect forward secrecy ciphersuites (DHE)
536     # and disallow AES-256 since AES-128 is just fine.
537     GnuTLSPriorities NORMAL:!DHE-RSA:!DHE-DSS:!AES-256-CBC:%COMPAT
538     DocumentRoot /www/
539     ServerName
540     GnuTLSCertificateFile conf/ssl/site1.crt
541     GnuTLSKeyFile conf/ss/site1.key
542     </VirtualHost>
543     <VirtualHost>
544     GnuTLSEnable on
545     # Here we instead of disabling the DHE ciphersuites we use
546     # Diffie Hellman parameters of smaller size than the default (2048 bits).
547     # Using small numbers from 768 to 1024 bits should be ok once they are
548     # regenerated every few hours.
549     # Use "certtool --generate-dh-params --bits 1024" to get those
550     GnuTLSDHFile /etc/apache2/dh.params
551     GnuTLSPriorities NORMAL:!AES-256-CBC:%COMPAT
552     DocumentRoot /www/
553     ServerName
554     GnuTLSCertificateFile conf/ssl/site2.crt
555     GnuTLSKeyFile conf/ss/site2.key
556     </VirtualHost>
558* * * * *
[2b16350]560Environment Variables
[2b16350]563`mod_gnutls` exports the following environment variables to scripts.
564These are compatible with `mod_ssl`.
[2b16350]569Can be `on` or `off`
[2b16350]574The version of the GnuTLS library
579The version of this module
[2b16350]584The SSL or TLS protocol name (such as `TLS 1.0` etc.)
589The SSL or TLS cipher suite name
[2b16350]594The negotiated compression method (`NULL` or `DEFLATE`)
599The SRP username used for authentication (only set when
[2b16350]600`GnuTLSSRPPasswdFile` and `GnuTLSSRPPasswdConfFile` are configured).
605The number if bits used in the used cipher algorithm.
607This does not fully reflect the security level since the size of
608RSA or DHE key exchange parameters affect the security level too.
613The number if bits in the modulus for the DH group, if DHE or static
614DH is used.
616This will not be set if DH is not used.
[2b16350]621`True` or `False`. Whether the cipher suite negotiated is an export one.
626The session ID negotiated in this session. Can be the same during client
632The number of days until the client's certificate is expired.
637The activation time of client's certificate.
642The expiration time of client's certificate.
647The distinguished name of client's certificate in RFC2253 format.
652The SSL or TLS cipher suite name
[2b16350]657These will contain the alternative names of the client certificate (`%` is
[4ee45a1]658a number starting from zero).
[2b16350]660The values will be prepended by `DNSNAME:`, `RFC822NAME:` or `URI:`
[4ee45a1]661depending on the type.
[2b16350]663If it is not supported the value `UNSUPPORTED` will be set.
668The serial number of the server's certificate.
673The version of the server's certificate.
678The algorithm used for the signature in server's certificate.
683The public key algorithm in server's certificate.
[999cdec]688The PEM-encoded (X.509) or ASCII-armored (OpenPGP) server certificate
689(see the `GnuTLSExportCertificates` directive).
[2b16350]694The certificate type can be `X.509` or `OPENPGP`.
699The PEM-encoded (X.509) or ASCII-armored (OpenPGP) client certificate
700(see the `GnuTLSExportCertificates` directive).
705The certificate type can be `X.509` or `OPENPGP`.
Note: See TracBrowser for help on using the repository browser.