Apache HTTP Server Version 2.4
Description: | Strong cryptography using the Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protocols |
---|---|
Status: | Extension |
Module Identifier: | ssl_module |
Source File: | mod_ssl.c |
This module provides SSL v3 and TLS v1.x support for the Apache HTTP Server. SSL v2 is no longer supported.
This module relies on OpenSSL to provide the cryptography engine.
Further details, discussion, and examples are provided in the SSL documentation.
This module can be configured to provide several items of SSL information
as additional environment variables to the SSI and CGI namespace. Except for
HTTPS
and SSL_TLS_SNI
which are always defined, this
information is not provided by default for performance reasons. (See
SSLOptions
StdEnvVars
, below)
The generated variables
are listed in the table below. For backward compatibility the information can
be made available under different names, too. Look in the Compatibility chapter for details on the
compatibility variables.
Variable Name | Value Type | Description |
---|---|---|
HTTPS | flag | HTTPS is being used. |
SSL_PROTOCOL | string | The SSL protocol version (SSLv3, TLSv1, TLSv1.1, TLSv1.2) |
SSL_SESSION_ID | string | The hex-encoded SSL session id |
SSL_SESSION_RESUMED | string | Initial or Resumed SSL Session. Note: multiple requests may be served over the same (Initial or Resumed) SSL session if HTTP KeepAlive is in use |
SSL_SECURE_RENEG | string | true if secure renegotiation is supported, else false |
SSL_CIPHER | string | The cipher specification name |
SSL_CIPHER_EXPORT | string | true if cipher is an export cipher |
SSL_CIPHER_USEKEYSIZE | number | Number of cipher bits (actually used) |
SSL_CIPHER_ALGKEYSIZE | number | Number of cipher bits (possible) |
SSL_COMPRESS_METHOD | string | SSL compression method negotiated |
SSL_VERSION_INTERFACE | string | The mod_ssl program version |
SSL_VERSION_LIBRARY | string | The OpenSSL program version |
SSL_CLIENT_M_VERSION | string | The version of the client certificate |
SSL_CLIENT_M_SERIAL | string | The serial of the client certificate |
SSL_CLIENT_S_DN | string | Subject DN in client's certificate |
SSL_CLIENT_S_DN_ x509 | string | Component of client's Subject DN |
SSL_CLIENT_SAN_Email_ n | string | Client certificate's subjectAltName extension entries of type rfc822Name |
SSL_CLIENT_SAN_DNS_ n | string | Client certificate's subjectAltName extension entries of type dNSName |
SSL_CLIENT_SAN_OTHER_msUPN_ n | string | Client certificate's subjectAltName extension entries of type otherName, Microsoft User Principal Name form (OID 1.3.6.1.4.1.311.20.2.3) |
SSL_CLIENT_I_DN | string | Issuer DN of client's certificate |
SSL_CLIENT_I_DN_ x509 | string | Component of client's Issuer DN |
SSL_CLIENT_V_START | string | Validity of client's certificate (start time) |
SSL_CLIENT_V_END | string | Validity of client's certificate (end time) |
SSL_CLIENT_V_REMAIN | string | Number of days until client's certificate expires |
SSL_CLIENT_A_SIG | string | Algorithm used for the signature of client's certificate |
SSL_CLIENT_A_KEY | string | Algorithm used for the public key of client's certificate |
SSL_CLIENT_CERT | string | PEM-encoded client certificate |
SSL_CLIENT_CERT_CHAIN_ n | string | PEM-encoded certificates in client certificate chain |
SSL_CLIENT_CERT_RFC4523_CEA | string | Serial number and issuer of the certificate. The format matches that of the CertificateExactAssertion in RFC4523 |
SSL_CLIENT_VERIFY | string | NONE , SUCCESS , GENEROUS or FAILED: reason |
SSL_SERVER_M_VERSION | string | The version of the server certificate |
SSL_SERVER_M_SERIAL | string | The serial of the server certificate |
SSL_SERVER_S_DN | string | Subject DN in server's certificate |
SSL_SERVER_SAN_Email_ n | string | Server certificate's subjectAltName extension entries of type rfc822Name |
SSL_SERVER_SAN_DNS_ n | string | Server certificate's subjectAltName extension entries of type dNSName |
SSL_SERVER_SAN_OTHER_dnsSRV_ n | string | Server certificate's subjectAltName extension entries of type otherName, SRVName form (OID 1.3.6.1.5.5.7.8.7, RFC 4985) |
SSL_SERVER_S_DN_ x509 | string | Component of server's Subject DN |
SSL_SERVER_I_DN | string | Issuer DN of server's certificate |
SSL_SERVER_I_DN_ x509 | string | Component of server's Issuer DN |
SSL_SERVER_V_START | string | Validity of server's certificate (start time) |
SSL_SERVER_V_END | string | Validity of server's certificate (end time) |
SSL_SERVER_A_SIG | string | Algorithm used for the signature of server's certificate |
SSL_SERVER_A_KEY | string | Algorithm used for the public key of server's certificate |
SSL_SERVER_CERT | string | PEM-encoded server certificate |
SSL_SRP_USER | string | SRP username |
SSL_SRP_USERINFO | string | SRP user info |
SSL_TLS_SNI | string | Contents of the SNI TLS extension (if supplied with ClientHello) |
x509 specifies a component of an X.509 DN; one of
C,ST,L,O,OU,CN,T,I,G,S,D,UID,Email
. In httpd 2.2.0 and
later, x509 may also include a numeric _n
suffix. If the DN in question contains multiple attributes of the
same name, this suffix is used as a zero-based index to select a
particular attribute. For example, where the server certificate
subject DN included two OU attributes, SSL_SERVER_S_DN_OU_0
and
SSL_SERVER_S_DN_OU_1
could be used to reference each. A
variable name without a _n
suffix is equivalent to that
name with a _0
suffix; the first (or only) attribute.
When the environment table is populated using
the StdEnvVars
option of
the SSLOptions
directive, the
first (or only) attribute of any DN is added only under a non-suffixed
name; i.e. no _0
suffixed entries are added.
In httpd 2.4.32 and later, an optional _RAW suffix may be
added to x509 in a DN component, to suppress conversion of
the attribute value to UTF-8. This must be placed after the index
suffix (if any). For example, SSL_SERVER_S_DN_OU_RAW
or
SSL_SERVER_S_DN_OU_0_RAW
could be used.
The format of the *_DN variables has changed in Apache HTTPD
2.3.11. See the LegacyDNStringFormat
option for
SSLOptions
for details.
SSL_CLIENT_V_REMAIN
is only available in version 2.1
and later.
A number of additional environment variables can also be used
in SSLRequire
expressions, or in custom log
formats:
HTTP_USER_AGENT PATH_INFO AUTH_TYPE HTTP_REFERER QUERY_STRING SERVER_SOFTWARE HTTP_COOKIE REMOTE_HOST API_VERSION HTTP_FORWARDED REMOTE_IDENT TIME_YEAR HTTP_HOST IS_SUBREQ TIME_MON HTTP_PROXY_CONNECTION DOCUMENT_ROOT TIME_DAY HTTP_ACCEPT SERVER_ADMIN TIME_HOUR THE_REQUEST SERVER_NAME TIME_MIN REQUEST_FILENAME SERVER_PORT TIME_SEC REQUEST_METHOD SERVER_PROTOCOL TIME_WDAY REQUEST_SCHEME REMOTE_ADDR TIME REQUEST_URI REMOTE_USER
In these contexts, two special formats can also be used:
ENV:variablename
HTTP:headername
When mod_ssl
is built into Apache or at least
loaded (under DSO situation) additional functions exist for the Custom Log Format of
mod_log_config
. First there is an
additional ``%{
varname}x
''
eXtension format function which can be used to expand any variables
provided by any module, especially those provided by mod_ssl which can
you find in the above table.
For backward compatibility there is additionally a special
``%{
name}c
'' cryptography format function
provided. Information about this function is provided in the Compatibility chapter.
CustomLog "logs/ssl_request_log" "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
These formats even work without setting the StdEnvVars
option of the SSLOptions
directive.
mod_ssl
sets "notes" for the request which can be
used in logging with the %{name}n
format
string in mod_log_config
.
The notes supported are as follows:
ssl-access-forbidden
1
if access was
denied due to an SSLRequire
or SSLRequireSSL
directive.ssl-secure-reneg
mod_ssl
is built against a version of
OpenSSL which supports the secure renegotiation extension, this note
is set to the value 1
if SSL is in used for the current
connection, and the client also supports the secure renegotiation
extension. If the client does not support the secure renegotiation
extension, the note is set to the value 0
.
If mod_ssl
is not built against a version of
OpenSSL which supports secure renegotiation, or if SSL is not in use
for the current connection, the note is not set.When mod_ssl
is built into Apache or at least
loaded (under DSO situation) any variables
provided by mod_ssl
can be used in expressions
for the ap_expr Expression Parser.
The variables can be referenced using the syntax
``%{
varname}
''. Starting
with version 2.4.18 one can also use the
mod_rewrite
style syntax
``%{SSL:
varname}
'' or
the function style syntax
``ssl(
varname)
''.
mod_headers
)Header set X-SSL-PROTOCOL "expr=%{SSL_PROTOCOL}" Header set X-SSL-CIPHER "expr=%{SSL:SSL_CIPHER}"
This feature even works without setting the StdEnvVars
option of the SSLOptions
directive.
mod_ssl
provides a few authentication providers for use
with mod_authz_core
's
Require
directive.
The ssl
provider denies access if a connection is not
encrypted with SSL. This is similar to the
SSLRequireSSL
directive.
Require ssl
The ssl
provider allows access if the user is
authenticated with a valid client certificate. This is only
useful if SSLVerifyClient optional
is in effect.
The following example grants access if the user is authenticated either with a client certificate or by username and password.
Require ssl-verify-client Require valid-user
Description: | File of concatenated PEM-encoded CA Certificates for Client Auth |
---|---|
Syntax: | SSLCACertificateFile file-path |
Context: | server config, virtual host |
Status: | Extension |
Module: | mod_ssl |
This directive sets the all-in-one file where you can assemble the
Certificates of Certification Authorities (CA) whose clients you deal
with. These are used for Client Authentication. Such a file is simply the
concatenation of the various PEM-encoded Certificate files, in order of
preference. This can be used alternatively and/or additionally to
SSLCACertificatePath
.
SSLCACertificateFile "/usr/local/apache2/conf/ssl.crt/ca-bundle-client.crt"
Description: | Directory of PEM-encoded CA Certificates for Client Auth |
---|---|
Syntax: | SSLCACertificatePath directory-path |
Context: | server config, virtual host |
Status: | Extension |
Module: | mod_ssl |
This directive sets the directory where you keep the Certificates of Certification Authorities (CAs) whose clients you deal with. These are used to verify the client certificate on Client Authentication.
The files in this directory have to be PEM-encoded and are accessed through
hash filenames. So usually you can't just place the Certificate files
there: you also have to create symbolic links named
hash-value.N
. And you should always make sure this directory
contains the appropriate symbolic links.
SSLCACertificatePath "/usr/local/apache2/conf/ssl.crt/"
Description: | File of concatenated PEM-encoded CA Certificates for defining acceptable CA names |
---|---|
Syntax: | SSLCADNRequestFile file-path |
Context: | server config, virtual host |
Status: | Extension |
Module: | mod_ssl |
When a client certificate is requested by mod_ssl, a list of acceptable Certificate Authority names is sent to the client in the SSL handshake. These CA names can be used by the client to select an appropriate client certificate out of those it has available.
If neither of the directives SSLCADNRequestPath
or SSLCADNRequestFile
are given, then the
set of acceptable CA names sent to the client is the names of all the
CA certificates given by the SSLCACertificateFile
and SSLCACertificatePath
directives; in other
words, the names of the CAs which will actually be used to verify the
client certificate.
In some circumstances, it is useful to be able to send a set of
acceptable CA names which differs from the actual CAs used to verify
the client certificate - for example, if the client certificates are
signed by intermediate CAs. In such cases, SSLCADNRequestPath
and/or SSLCADNRequestFile
can be used; the
acceptable CA names are then taken from the complete set of
certificates in the directory and/or file specified by this pair of
directives.
SSLCADNRequestFile
must
specify an all-in-one file containing a concatenation of
PEM-encoded CA certificates.
SSLCADNRequestFile "/usr/local/apache2/conf/ca-names.crt"
Description: | Directory of PEM-encoded CA Certificates for defining acceptable CA names |
---|---|
Syntax: | SSLCADNRequestPath directory-path |
Context: | server config, virtual host |
Status: | Extension |
Module: | mod_ssl |
This optional directive can be used to specify the set of
acceptable CA names which will be sent to the client when a
client certificate is requested. See the SSLCADNRequestFile
directive for more
details.
The files in this directory have to be PEM-encoded and are accessed
through hash filenames. So usually you can't just place the
Certificate files there: you also have to create symbolic links named
hash-value.N
. And you should always make sure
this directory contains the appropriate symbolic links.
SSLCADNRequestPath "/usr/local/apache2/conf/ca-names.crt/"
Description: | Enable CRL-based revocation checking |
---|---|
Syntax: | SSLCARevocationCheck chain|leaf|none [flags ...] |
Default: | SSLCARevocationCheck none |
Context: | server config, virtual host |
Status: | Extension |
Module: | mod_ssl |
Compatibility: | Optional flags available in httpd 2.4.21 or later |
Enables certificate revocation list (CRL) checking. At least one of
SSLCARevocationFile
or SSLCARevocationPath
must be
configured. When set to chain
(recommended setting),
CRL checks are applied to all certificates in the chain, while setting it to
leaf
limits the checks to the end-entity cert.
The available flags are:
no_crl_for_cert_ok
Prior to version 2.3.15, CRL checking in mod_ssl also succeeded when
no CRL(s) for the checked certificate(s) were found in any of the locations
configured with SSLCARevocationFile
or SSLCARevocationPath
.
With the introduction of SSLCARevocationFile
,
the behavior has been changed: by default with chain
or
leaf
, CRLs must be present for the
validation to succeed - otherwise it will fail with an
"unable to get certificate CRL"
error.
The flag no_crl_for_cert_ok
allows to restore
previous behaviour.
SSLCARevocationCheck chain
SSLCARevocationCheck chain no_crl_for_cert_ok
Description: | File of concatenated PEM-encoded CA CRLs for Client Auth |
---|---|
Syntax: | SSLCARevocationFile file-path |
Context: | server config, virtual host |
Status: | Extension |