mod_gnutls uses the "configure/make/make install" mechanism common to many Open Source programs.
Most of the dirty work is handled by either configure or Apache's apxs utility.
If you have built Apache modules before, there shouldn't be any surprises for you.
The interesting options you can pass to configure are:
--with-apxs=PATH
This option is used to specify the location of the apxs utility that was installed as part of apache.
Specify the location of the binary, not the directory it is located in.
--with-libgnutls=PATH
Full path to the libgnutls-config program.
--with-apr-memcache=PREFIX
Prefix to where apr_memcache is installed.
--help
Provides a list of all available configure options.
To activate mod_gnutls just add the following line to your httpd.conf and restart Apache:
LoadModule gnutls_module modules/mod_gnutls.so
This directive configures the SSL Session Cache for mod_gnutls.
This could be shared between machines of different architectures.
dbm (Requires Berkeley DBM)
Uses the default Berkeley DB backend of APR DBM to cache SSL Sessions results.
The argument is a relative or absolute path to be used as the DBM Cache file.
This is compatible with most operating systems, but needs the Apache Runtime to be compiled with Berkeley DBM support.
gdbm
Uses the GDBM backend of APR DBM to cache SSL Sessions results.
The argument is a relative or absolute path to be used as the DBM Cache file.
This is the default and recommended option.
memcache
Uses a memcached server to cache the SSL Session.
The argument is a space separated list of servers. If no port number is supplied, the default of 11211 is used.
This can be used to share a session cache between all servers in a cluster.
none
Turns off all caching of SSL Sessions.
This can significantly reduce the performance of mod_gnutls since even followup connections by a client must renegotiate parameters instead of reusing old ones.
Sets the timeout for SSL Session Cache entries expiration.
This directive is valid even if Session Tickets are used, and indicates the expiration time of the ticket.
To avoid storing data for TLS session resumption it is allowed to provide client with a ticket, to use on return.
Use for servers with limited storage, and don't combine with GnuTLSCache.
For a pool of servers this option is not recommended since the tickets are unique for the issuing server only.
Takes an absolute or relative path to a PEM Encoded Certificate to use as this Server's Certificate.
Takes an absolute or relative path to the Server Private Key.
This key cannot currently be password protected.
Security Warning:
This private key must be protected. It is read while Apache is still running as root, and does not need to be readable by the nobody or apache user.
Takes an absolute or relative path to a base64 Encoded OpenPGP Certificate to use as this Server's Certificate.
Takes an absolute or relative path to the Server Private Key. This key cannot currently be password protected.
Security Warning:
This private key must be protected. It is read while Apache is still running as root, and does not need to be readable by the nobody or apache user.
This directive controls the use of SSL Client Certificate Authentication.
If used in the .htaccess context, it can force TLS re-negotiation.
ignore
mod_gnutls will ignore the contents of any SSL Client Certificates sent.
It will not request that the client sends a certificate.
request
The client certificate will be requested, but not required.
The Certificate will be validated if sent.
The output of the validation status will be stored in the SSL_CLIENT_VERIFY environment variable and can be "SUCCESS", "FAILED" or "NONE".
require
A Client certificate will be required. Any requests without a valid client certificate will be denied.
The SSL_CLIENT_VERIFY environment variable will only be set to "SUCCESS".
Takes an absolute or relative path to a PEM Encoded Certificate to use as a Certificate Authority with Client Certificate Authentication.
This file may contain a list of trusted authorities.
Takes an absolute or relative path to a base64 Encoded Certificate list (key ring) to use as a means of verification of Client Certificates.
This file should contain a list of trusted signers.
This directive enables SSL/TLS Encryption for a Virtual Host.
Takes an absolute or relative path to a PKCS #3 encoded DH parameters.
Those are used when the DHE key exchange method is enabled.
You can generate this file using "certtool --generate-dh-params --bits 2048".
If not set mod_gnutls will use the included parameters.
Takes an absolute or relative path to a PKCS #1 encoded RSA parameters.
Those are used when the RSA-EXPORT key exchange method is enabled.
You can generate this file using "certtool --generate-privkey --bits 512".
These parameters should not contain a key longer than 512 bits (due to the export restrictions).
If not set mod_gnutls will not negotiate the 'EXPORT' ciphersuites.
It is recommended not to enable those ciphersuites.
If you do make sure you regenerate this file at every few hours.
Takes an absolute or relative path to an SRP password file. This is the same format as used in libsrp.
You can generate such file using the command "srptool --passwd /etc/tpasswd --passwd-conf /etc/tpasswd.conf -u test" to set a password for user test.
This password file holds the username, a password verifier and the dependency to the SRP parameters.
Takes an absolute or relative path to an SRP password.conf file. This is the same format as used in libsrp.
You can generate such file using the command "srptool --create-conf /etc/tpasswd.conf".
This file holds the SRP parameters and is associate with the password file (the verifiers depends on these parameters).
Takes a semi-colon separated list of ciphers, key exchange methods
Message authentication codes and compression methods to enable.
The allowed keywords are specified in the gnutls_priority_init() function of GnuTLS.
It's documentation can be found at Core GnuTLS functions.
In brief you can specify a set of ciphersuites from the choices:
Additionally you can add or remove algorithms using the "+" and "!" prefixes respectively.
That is in order to disable the ARCFOUR cipher from the "NORMAL" set you can use the string NORMAL:!ARCFOUR-128
Other options such as the protocol version and the compression method can be specified using the VERS- and COMP- prefixes.
So in order to remove or add a specific TLS version from the "NORMAL" set use NORMAL:!VERS-SSL3.0.
To enable zlib compression use NORMAL:+COMP-DEFLATE.
However it is recommended not to add compression at this level.
With the "NONE" set, in order to be usable, you have to specify a complete set of combinations of protocol versions,
cipher algorithms (AES-128-CBC), key exchange algorithms (RSA), message authentication codes (SHA1) and compression methods (COMP-NULL).
All the supported algorithms are:
The special keyword "%COMPAT" will disable some security features such as protection against statistical attacks to ciphertext data in order to achieve maximum compatibility (some broken mobile clients need this).
This directive enables exporting the full PEM encoded certificates of the server and the client to CGIs.
This makes mod_gnutls export exactly the same environment variables as mod_ssl.
The following is an example of standard SSL Hosting, using one IP Addresses for each virtual host
# Load the module into Apache.
LoadModule gnutls_module modules/mod_gnutls.so
GnuTLSCache gdbm /var/cache/www-tls-cache
GnuTLSCacheTimeout 500
# With normal SSL Websites, you need one IP Address per-site.
Listen 1.2.3.1:443
Listen 1.2.3.2:443
Listen 1.2.3.3:443
Listen 1.2.3.4:443
<VirtualHost 1.2.3.1:443>
GnuTLSEnable on
GnuTLSPriorities NONE:+AES-128-CBC:+3DES-CBC:+ARCFOUR-128:+RSA:+DHE-RSA:+DHE-DSS:+SHA1:+MD5:+COMP-NULL
DocumentRoot /www/site1.example.com/html
ServerName site1.example.com:443
GnuTLSCertificateFile conf/ssl/site1.crt
GnuTLSKeyFile conf/ss/site1.key
</VirtualHost>
<VirtualHost 1.2.3.2:443>
# This virtual host enables SRP authentication
GnuTLSEnable on
GnuTLSPriorities NORMAL:+SRP
DocumentRoot /www/site2.example.com/html
ServerName site2.example.com:443
GnuTLSSRPPasswdFile conf/ssl/tpasswd.site2
GnuTLSSRPPasswdConfFile conf/ssl/tpasswd.site2.conf
</VirtualHost>
<VirtualHost 1.2.3.3:443>
# This server enables SRP, OpenPGP and X.509 authentication.
GnuTLSEnable on
GnuTLSPriorities NORMAL:+SRP:+SRP-RSA:+SRP-DSS
DocumentRoot /www/site3.example.com/html
ServerName site3.example.com:443
GnuTLSCertificateFile conf/ssl/site3.crt
GnuTLSKeyFile conf/ss/site3.key
GnuTLSClientVerify ignore
GnuTLSPGPCertificateFile conf/ss/site3.pub.asc
GnuTLSPGPKeyFile conf/ss/site3.sec.asc
GnuTLSSRPPasswdFile conf/ssl/tpasswd.site3
GnuTLSSRPPasswdConfFile conf/ssl/tpasswd.site3.conf
</VirtualHost>
<VirtualHost 1.2.3.4:443>
GnuTLSEnable on
# %COMPAT disables some security features to enable maximum compatibility with clients.
GnuTLSPriorities NONE:+AES-128-CBC:+ARCFOUR-128:+RSA:+SHA1:+MD5:+COMP-NULL:%COMPAT
DocumentRoot /www/site4.example.com/html
ServerName site4.example.com:443
GnuTLSCertificateFile conf/ssl/site4.crt
GnuTLSKeyFile conf/ss/site4.key
</VirtualHost>
mod_gnutls can also use 'Server Name Indication', as specified in RFC 3546.
# Load the module into Apache.
This allows hosting many SSL Websites, with a Single IP Address.M
Currently all the recent browsers support this standard.
Here is an example, using SNI:
LoadModule gnutls_module modules/mod_gnutls.so
# With normal SSL Websites, you need one IP Address per-site.
Listen 1.2.3.1:443
# This could also be 'Listen *:443',
# just like '*:80' is common for non-https
# No caching. Enable session tickets. Timeout is still used for
# ticket expiration.
GnuTLSCacheTimeout 600
# This tells apache, that for this IP/Port combination, we want to use
# Name Based Virtual Hosting. In the case of Server Name Indication,
# it lets mod_gnutls pick the correct Server Certificate.
NameVirtualHost 1.2.3.1:443
<VirtualHost 1.2.3.1:443>
GnuTLSEnable on
GnuTLSSessionTickets on
GnuTLSPriorities NORMAL
DocumentRoot /www/site1.example.com/html
ServerName site1.example.com:443
GnuTLSCertificateFile conf/ssl/site1.crt
GnuTLSKeyFile conf/ss/site1.key
</VirtualHost>
<VirtualHost 1.2.3.1:443>
GnuTLSEnable on
GnuTLSPriorities NORMAL
DocumentRoot /www/site2.example.com/html
ServerName site2.example.com:443
GnuTLSCertificateFile conf/ssl/site2.crt
GnuTLSKeyFile conf/ss/site2.key
</VirtualHost>
<VirtualHost 1.2.3.1:443>
GnuTLSEnable on
GnuTLSPriorities NORMAL
DocumentRoot /www/site3.example.com/html
ServerName site3.example.com:443
GnuTLSCertificateFile conf/ssl/site3.crt
GnuTLSKeyFile conf/ss/site3.key
</VirtualHost>
<VirtualHost 1.2.3.1:443>
GnuTLSEnable on
GnuTLSPriorities NORMAL
DocumentRoot /www/site4.example.com/html
ServerName site4.example.com:443
GnuTLSCertificateFile conf/ssl/site4.crt
GnuTLSKeyFile conf/ss/site4.key
</VirtualHost>
mod_gnutls by default uses conservative settings for the server.
You can fine tune the configuration to reduce the load on a busy server.
The following examples do exactly this:
# Load the module into Apache.
LoadModule gnutls_module modules/mod_gnutls.so
# Using 4 memcache servers to distribute the SSL Session Cache.
GnuTLSCache memcache "mc1.example.com mc2.example.com mc3.example.com mc4.example.com"
GnuTLSCacheTimeout 600
Listen 1.2.3.1:443
NameVirtualHost 1.2.3.1:443
<VirtualHost 1.2.3.1:443>
GnuTLSEnable on
# Here we disable the Perfect forward secrecy ciphersuites (DHE)
# and disallow AES-256 since AES-128 is just fine.
GnuTLSPriorities NORMAL:!DHE-RSA:!DHE-DSS:!AES-256-CBC:%COMPAT
DocumentRoot /www/site1.example.com/html
ServerName site1.example.com:443
GnuTLSCertificateFile conf/ssl/site1.crt
GnuTLSKeyFile conf/ss/site1.key
</VirtualHost>
<VirtualHost 1.2.3.1:443>
GnuTLSEnable on
# Here we instead of disabling the DHE ciphersuites we use
# Diffie Hellman parameters of smaller size than the default (2048 bits).
# Using small numbers from 768 to 1024 bits should be ok once they are
# regenerated every few hours.
# Use "certtool --generate-dh-params --bits 1024" to get those
GnuTLSDHFile /etc/apache2/dh.params
GnuTLSPriorities NORMAL:!AES-256-CBC:%COMPAT
DocumentRoot /www/site2.example.com/html
ServerName site2.example.com:443
GnuTLSCertificateFile conf/ssl/site2.crt
GnuTLSKeyFile conf/ss/site2.key
</VirtualHost>
mod_gnutls exports the following environment variables to scripts.
These are compatible with mod_ssl.
Can be "on" or "off"
The version of the gnutls library
The version of this module
The SSL or TLS protocol name (such as "TLS 1.0" etc.)
The SSL or TLS cipher suite name
The negotiated compression method (NULL or DEFLATE)
The SRP username used for authentication.
The number if bits used in the used cipher algorithm.
This does not fully reflect the security level since the size of
RSA or DHE key exchange parameters affect the security level too.
True or False. Whether the cipher suite negotiated is an export one.
The session ID negotiated in this session. Can be the same during client reloads.
The number of days until the client's certificate is expired.
The activation time of client's certificate.
The expiration time of client's certificate.
The distinguished name of client's certificate in RFC2253 format.
The SSL or TLS cipher suite name
These will contain the alternative names of the client certificate (% is a number starting from zero).
The values will be prepended by "DNSNAME:", "RFC822NAME:" or "URI:" depending on the type.
If it is not supported the value "UNSUPPORTED" will be set.
The serial number of the server's certificate.
The version of the server's certificate.
The algorithm used for the signature in server's certificate.
The public key algorithm in server's certificate.
The PEM-encoded server certificate.
The certificate type can be X.509 or OPENPGP.