SCEP Certificate Lifecycle Operations
The Horizon Client includes a SCEP client to perform challenge based pre-validated enrollments and renewals. Its usage is similar to that of the EST client in challenge mode.
Usage:
horizon-cli scep [command] [flags]
SCEP Enrollment
The enroll
command allows you to perform a SCEP enrollment operation. It will generate a new key pair and a CSR based on the content parameters, and send it to the SCEP server to obtain a certificate.
Validation
Get a SCEP challenge password from the Horizon web app or REST API. You can then provide it with the --challenge
parameter to the enroll
command.
Content Parameters
You can customize the contents of the CSR using the following parameters:
Parameter | Description |
---|---|
|
SCEP Profile to use |
|
SCEP pre-validated request challenge |
|
Path to the certificate file to be written |
|
Path to the key file to be written |
|
Common Name of the certificate to request |
|
Organizational Units of the certificate to request |
|
SAN DNS Names of the certificate to request |
|
SAN IP Addresses of the certificate to request |
|
SAN RFC822 Names of the certificate to request |
|
Contact email |
|
Certificate owner |
|
Certificate owning team |
|
Labels, in the form key:value |
|
Path to write the CA Chain to be written, as a PEM Bundle |
|
Path to write the PKCS#12 output to be written |
|
Password for the PKCS#12 output |
|
Type and size of the key to generate (defaults to |
|
Bash or powershell script to execute upon enrollment completion. See script section |
|
Discovery profile to use in order to report the certificate to Horizon after enrollment |
|
Path to write the JKS output to be written |
|
Password for the JKS output |
|
Alias for the JKS output |
|
Password for the alias in the JKS output |
|
Overwrite existing files |
SCEP Renewal
The renew
command is designed to work similarly to the enroll
command, but with a few differences:
-
It will enroll a certificate based on the
--in-cert
parameter (or similar, see below) instead of the content parameters. Only the--key-type
parameter is used to generate a new key pair. -
No challenge is needed for a SCEP renewal operation
The following input parameters can be used to specify the certificate to renew:
Parameter | Description |
---|---|
|
SCEP Profile to use |
|
Key type |
|
Contact email |
|
Certificate owner |
|
Certificate owning team |
|
Labels, in the form key:value |
|
Discovery profile to use in order to report the certificate to Horizon after renewal |
|
Path to the Certificate to renew (PEM file, PKCS#12 file, JKS file) or cert thumbprint for Windows certificate store entries |
|
Password for the PKCS#12 file to renew |
|
Password for the JKS file to renew |
|
Alias for the certificate to renew in the JKS file |
|
Alias password for the JKS file to renew |
|
Path to the Certificate to save as a PEM file |
|
Path to the Key to save as a PEM file |
|
Path to the Chain to save as a PEM file |
|
Path to write the PKCS#12 output |
|
Password for the PKCS#12 output. Mandatory if |
|
Path to write the JKS output |
|
Password for the JKS output. Mandatory if |
|
Alias for the JKS output. Mandatory if |
|
Password for the alias in the JKS output. Mandatory if |
|
Execute bash or powershell script upon enrollment or renewal completion. See script section |
|
Number of days before expiration to trigger the renewal. Optional, renewal modeonly |
Output Parameters
Choose how the created certificate and its associated private key are stored. The following alternatives are available:
-
Key and certificate stored separately in two files, in PEM format. This is typically used to be used by Apache or NGINX web servers;
-
Key and certificate stored together in a PKCS#12 or JKS file. This is typically used by Tomcat application server;
-
Key and certificate stored together in Windows certificate store. This is typically used by IIS web server.
Parameter | Description |
---|---|
|
Path to the private key to store |
|
Path to the certificate to store |
|
Path to the PKCS#12 file storing the certificate and its key |
|
Password used to encrypt the PKCS#12 file specified in the |
|
Path to export the certificate and private key as JKS. Optional |
|
Password used to encrypt the JKS file specified in the |
|
Alias of the private key entry within the JKS |
|
Password of the private key entry within the JKS |
Metadata parameters
Each certificate enrolled via horizon must have a profile, specified with the --profile
flag. You can add extra metadata according to your needs using the following parameters:
Parameter | Description |
---|---|
|
Owner of the certificate |
|
Contact email of the certificate owner |
|
Team owning the certificate |
|
Labels to attach to the certificate, in the form |
Discovery parameter
You can chain a certificate enrollment operation with the discovery operation by using the --discovery
parameter. It will use the APIID
and APIKey
defined in the general configuration to authenticate to Horizon and feed it with the enrolled certificate and its discovery metadata.
The --discovery
parameter takes a value, which is the name of the Discovery campaign to use to report the certificate to Horizon.
Script parameter
You can tell Horizon Client to launch a script upon successful certificate enrollment or renewal by using the --script
parameter, which takes the path to the script as an argument.
The script will receive arguments passed by Horizon Client in the following order:
-
Issued certificate serial number
-
Issued certificate fingerprint (SHA-1 hash of the certificate in DER format - windows store thumbprint)
-
Issued certificate Subject DN
-
Issued certificate Issuer DN
Below is an example of a very simple bash script:
#!/bin/sh
echo $1
echo $2
echo $3
echo $4
Below is an example of a very simple PowerShell script:
param($serial, $fingerprint, $subject, $issuer)
Write-Output $serial
Write-Output $fingerprint
Write-Output $subject
Write-Output $issuer
Examples
You will find below a few examples detailing how to use the client for SCEP enrollment in various context
Enrollment with output as key and certificate
horizon-cli scep enroll --profile=<profile> --challenge=<challenge> --cn=test.example.com --dnsnames=test.example.com,www.test.example.com --cert=/path/to/cert --key=/path/to/key
Enrollment with lots of metadata and output as PKCS#12
horizon-cli scep enroll \
--profile=<profile> \
--challenge=<challenge> \
--key-type=rsa-2048 \
--cn=test.example.com \
--dnsnames=test.example.com,www.test.example.com \
--owner="John Doe" \
--ou="IT" \
--team="IT" \
--labels="env:prod" \
--pfx=/path/to/pkcs12 \
--pfx-pwd=<pkcs12_password>