Provider Backend Module

Sign certificates using certificates and keys at a URI using the OpenSSL provider mechanism. The URI could describe a PEM file, a smartcard, or an HSM, or any combination thereof.

What does it do?

This module provides set of signing functions that can be used to sign certificate sign requests backed with the OpenSSL provider mechanism.

The OpenSSL provider mechanism allows access to certificates and key described by a URI. The default URI scheme is file:, representing the URL of a file on disk.

Based on the configuration, this module performs signing of an incoming certificate sign request using a certificate and key stored in a PEM file, on an HSM, TPM or smartcard.

Finding Certificates and Keys

The certificate and key used to sign a request can be defined precisely in the URIs for CAProviderCertificate and CAProviderKey.

Alternatively, when the URIs are defined broadly to match multiple certificates or keys, this module will choose the best certificate and key found at the corresponding URIs. This allows you to define a generic URI such as pkcs11: and this module will automatically choose the certificate and key based on what is available on the smartcard or HSM.

To choose the certificate and key, this module performs the following steps.

  • All keys are read from the CAProviderKey URI.
  • All intermediate certificates are read from the CAProviderCertificate URI, leaf certificates are ignored.
  • Intermediate certificates are matched up with their keys, any certificates without keys, or keys without certificates, are ignored.
  • The most recently issued certificate is chosen for signing.

Module Integration

The mod_ca_provider module is a backend module and will not do anything useful until mod_ca_provider has been combined with one or more frontend modules and optional backend modules listed below. The mod_ca_provider module provides the following hooks, and suitable frontend modules must be configured to implement each protocol as needed.

All backend modules run within a standard Apache httpd request, and standard httpd functionality applies in all cases.

Sign Request Hook

When this hook is triggered, this module signs the certificate sign request using a certificate available at the URI specified in the CAProviderCertificate directive, and a private key specified at the URI specified in the CAProviderKey directive. These URIs may point at the same location, or different locations as needed.

This module provides the following implementations of this hook.

Provider Sign Request Signs the certificate sign request using a key stored in a PEM file, on an HSM or smartcard, described by a URI.

This hook is called by the following frontend modules.

mod_csr Generate and issue certificates in response to an X509 certificate request.
mod_pkcs12 Generate public/private key pairs and and issue certificates in response to a application/x-www-form-urlencoded form request.
mod_scep Generate and issue certificates using the SCEP protocol.
mod_spkac Generate and issue certificates using the SPKAC protocol.

Get Chain Hook

When this hook is triggered, this module returns the intermediate certificate chain used to sign certificate sign requests, if any and present.

The intermediate certificate chain is retrieved from the URI pointed to by the CAProviderChain directive, and may be omitted if no chain exists between the signing certificate and the CA certificate.

This module provides the following implementations of this hook.

mod_ca_provider This hook returns the certificate chain of a certificate provided by an OpenSSL provider URI.

This hook is called by the following backend modules.

mod_ca_engine This hook signs a given certificate sign request using an OpenSSL provided crypto engine such as a smartcard, and including the chain defined by the module.
mod_ca_provider This hook signs a given certificate sign request using an OpenSSL provider URI, returning a the chain defined by the module.
mod_ca_simple This hook signs a given certificate sign request, returning a the chain defined by the module.

Make Serial Hook

When this hook is triggered, the Sign Request Hook asks for a serial number to use when signing the certificate.

Implementations of this hook are provided by other modules.

Make Next Serial From Disk Returns the next serial number from the contents of a file on disk.
Simple Make Serial From Subject Returns the serial number from that embedded within the subject of the certificate sign request.
Simple Make Random Serial Returns a random serial number.

This hook is called by the following frontend modules and backend modules.

mod_ca_engine This hook signs a given certificate sign request using an OpenSSL provided crypto engine such as a smartcard, using the serial number returned by this module.
mod_ca_provider This hook signs a given certificate sign request using an OpenSSL provider URI, using the serial number returned by this module.
mod_ca_simple This hook signs a given certificate sign request, using the serial number returned by this module.
mod_timestamp Parse and return responses to RFC3161 Time Stamp Protocol requests.

Get Time Hook

When this hook is triggered, the Sign Request Hook asks for the time to use when signing the certificate.

Implementations of this hook are provided by other modules.

mod_ca_simple This hook returns the time to be used to sign a certificate sign request, derived from the system time.

This hook is called by the following frontend modules and backend modules.

mod_ca_engine This hook signs a given certificate sign request using an OpenSSL provided crypto engine such as a smartcard, using the time returned by this module.
mod_ca_provider This hook signs a given certificate sign request using an OpenSSL provider URI, using the time returned by this module.
mod_ca_simple This hook signs a given certificate sign request, using the time returned by this module.
mod_timestamp Parse and return responses to RFC3161 Time Stamp Protocol requests.

Get Certificate Authority Hook

When this hook is triggered, this module returns the root CA certificate used to sign certificate sign requests.

This module provides the following implementations of this hook.

Provider Get Certificate Authority Returns the certificate authority certificate used to sign the request.

This hook is called by the following frontend modules.

mod_ocsp Respond with the revocation status of a certificate.
mod_scep Generate and issue certificates using the SCEP protocol.

Get Next Certificate Authority Hook

When this hook is triggered, this module returns the next root CA certificate that will in future be used to sign certificate sign requests.

This module provides the following implementations of this hook.

Provider Get Next Certificate Authority Returns the next certificate authority certificate that will be used to sign future requests.

This hook is called by the following frontend modules.

mod_scep Generate and issue certificates using the SCEP protocol.

Examples

Basic Example

The simplest case: issue a certificate to anybody who wants one.


# global configuration
<IfModule mod_ca_provider.c>
  # accept PKCS11 URIs
  CAProvider pkcs11
  # accept file: URIs
  CAProvider default
</IfModule>

# backend configuration:
<IfModule mod_ca_simple.c>
  # use system clock as the time source
  CASimpleTime on
  # assign a random serial number
  CASimpleSerialRandom on
</IfModule>
<IfModule mod_ca_provider.c>
  # sign with this certificate...
  CAProviderCertificate file:/etc/pki/tls/signing-cert.pem
  # ...and private key...
  CAProviderKey "${KEYURI}"
  # ...and private key PIN if needed
  CAProviderPassphrase "${KEYPIN}"
  # ...and using this CA certificate
  CAProviderCA file:/etc/pki/tls/ca-cert.pem
  # add extensions for a typical CA
  CAProviderExtension basicConstraints CA:FALSE
  CAProviderExtension keyUsage critical,nonRepudiation,digitalSignature,keyEncipherment
  CAProviderExtension extendedKeyUsage OID:1.3.6.1.5.5.7.3.2
  CAProviderExtension subjectKeyIdentifier hash
  CAProviderExtension authorityKeyIdentifier keyid,issuer
</IfModule>

# frontend configuration:
<IfModule mod_csr.c>
  <Location /csr>
    SetHandler csr
    # use subject from the certificate sign request unmodified
    CsrSubjectRequest *
  </Location>
</IfModule>

Hook Implementation Reference

The following backend hook implementations are provided by this module.

Provider Sign Request

Signs the certificate sign request using a certificate and key stored at a URI.

Both the CAProviderCertificate directive and the CAProviderKey directive are needed to enable the hook implementation. In addition, both the Make Serial Hook and the Get Time Hook are called to fill in the serial number and signing time for the certificate.

Each certificate is signed by default for 365 days. This can be controlled by the CAProviderDays directive. The CAProviderExtension directive allows certificate extensions to be added to the certificate.

Provider Get Certificate Authority

Returns the certificate authority certificate used to sign the request.

The certificate authority certificate(s) are parsed from the URI pointed to by the CAProviderCA directive and returned when requested.

Provider Get Next Certificate Authority

Returns the next certificate authority certificate that will be used to sign future requests.

The next certificate authority certificate(s) are parsed from the URI pointed to by the CAProviderNextCertificate directive and returned when requested.

Provider Get Chain

Returns the chain of certificates used to sign the request.

The certificate chain is parsed from the CAProviderChain directive(s) and returned when requested.

Directive Reference

CAProviderCertificate Directive

Description URI of the signing certificate(s)
Syntax CAProviderCertificate uri [propq]
Default none
Context server config, virtual host, directory, .htaccess
Status Backend
Module mod_ca_provider
Compatibility Introduced in mod_ca 1.0.0 and works with Apache HTTP Server 2.4.0 and later

Set to the URI of the signing certificate(s). An optional property query can be specified as needed.

When multiple signing certificates are found, all leaf certificates are ignored, as well as all certificates that do not match the private keys defined by CAProviderKey. Of the remaining certificates, the most recently issued certificate is used for signing.

CAProviderKey Directive

Description Set to the URI of the signing key(s) on the smartcard or HSM.
Syntax CAProviderKey uri [propq]
Default none
Context server config, virtual host, directory, .htaccess
Status Backend
Module mod_ca_provider
Compatibility Introduced in mod_ca 1.0.0 and works with Apache HTTP Server 2.4.0 and later

Set to the URI of the signing key(s) on the smartcard or HSM. An optional property query can be specified as needed.

When multiple signing keys are found, keys are matched to all non-leaf certificates defined by CAProviderCertificate. Of the matching signing certificates, the most recently issued certificate is used for signing.

Examples of URIs include:


# backend configuration:
<IfModule mod_ca_provider.c>
  CAProviderKey "pkcs11:model=PKCS%2315;manufacturer=EnterSafe;serial=1234567890123456;token=User%20PIN%20%28My%20Token%29;object=Certificate"
</IfModule>

CAProviderChain Directive

Description URI of the chain certificate(s), if any.
Syntax CAProviderChain uri [propq]
Default none
Context server config, virtual host, directory, .htaccess
Status Backend
Module mod_ca_provider
Compatibility Introduced in mod_ca 1.0.0 and works with Apache HTTP Server 2.4.0 and later

Set to the URI of the chain certificate(s). Can be specified more than once. An optional property query can be specified as needed.

CAProviderCA Directive

Description URI of the CA certificate, if any.
Syntax CAProviderCA uri [propq]
Default none
Context server config, virtual host, directory, .htaccess
Status Backend
Module mod_ca_provider
Compatibility Introduced in mod_ca 1.0.0 and works with Apache HTTP Server 2.4.0 and later

Set to the URI of the CA certificate. Can be specified more than once. An optional property query can be specified as needed.

CAProviderNextCA Directive

Description URI of the next CA certificate to follow this one, if any.
Syntax CAProviderNextCA uri [propq]
Default none
Context server config, virtual host, directory, .htaccess
Status Backend
Module mod_ca_provider
Compatibility Introduced in mod_ca 1.0.0 and works with Apache HTTP Server 2.4.0 and later

Set to the URI of the next CA certificate to follow this one, if any. Can be specified more than once. An optional property query can be specified as needed.

CAProviderDays Directive

Description Set to the number of days the certificate must be signed for.
Syntax CAProviderDays days
Default CAProviderDays 365
Context server config, virtual host, directory, .htaccess
Status Backend
Module mod_ca_provider
Compatibility Introduced in mod_ca 1.0.0 and works with Apache HTTP Server 2.4.0 and later

Set to the number of days the certificate must be signed for.

Defaults to 365 days.

CAProviderExtension Directive

Description Certificate extension to add to the certificate when signed.
Syntax CAProviderExtension string
Default none
Context server config, virtual host, directory, .htaccess
Status Backend
Module mod_ca_provider
Compatibility Introduced in mod_ca 1.0.0 and works with Apache HTTP Server 2.4.0 and later

Certificate extension to add to the certificate when signed.

Examples of certificate extensions include:


# backend configuration:
<IfModule mod_ca_provider.c>
  CAProviderExtension basicConstraints CA:FALSE
  CAProviderExtension keyUsage critical,nonRepudiation,digitalSignature,keyEncipherment
  CAProviderExtension extendedKeyUsage OID:1.3.6.1.5.5.7.3.2
  CAProviderExtension subjectKeyIdentifier hash
  CAProviderExtension authorityKeyIdentifier keyid,issuer
</IfModule>

CAProvider Directive

Description Name of the OpenSSL provider to use.
Syntax CAProvider string [key=value ...]
Default none
Context server config, virtual host, directory, .htaccess
Status Backend
Module mod_ca_provider
Compatibility Introduced in mod_ca 1.0.0 and works with Apache HTTP Server 2.4.0 and later

Name of the OpenSSL provider to use.

Additonal options can be specified for each provider by passing name value pairs after the provider name.

Providers defined in this module have a scope limited to this module, and configuration specified here will have no effect on other parts of the server. This is a property of OpenSSL v3 and above.

Examples of crypto providers include:


# backend configuration:
<IfModule mod_ca_provider.c>
  CAProvider pkcs11
  CAProvider default
</IfModule>