dioptra-ssl Command Reference#

dioptra-ssl creates certificate authorities, issues server certificates and validates certificate files. It is supplied by the dioptra-platform Python package and can be used without a Dioptra deployment.

See also

For Docker deployment initialization and certificate replacement, see init-deployment.sh Script Reference and manage_ssl.py Command Reference.

For interrupted standalone certificate creation, see Recover from Interrupted Certificate Creation.

Syntax#

dioptra-ssl COMMAND [OPTIONS]

See Argument Values for shared path, date, DNS-name and IP-address rules.

Command Summary#

Commands#

Command

Purpose

create-ca

Create a private CA key and self-signed CA certificate.

issue

Create a server key and certificate signed by an explicitly selected CA.

validate

Check existing certificates and, optionally, their private keys without modifying them.

Common Options#

These options are available after any command name.

--format <text|json>#

Select the output format. text produces human-readable output and is the default. json produces structured JSON.

--help#

Display help for the command and exit.

create-ca#

Creates an RSA private key and a self-signed CA certificate using SHA-256. Use this CA to issue server certificates with the issue command.

Syntax#

dioptra-ssl create-ca --key-out PATH --cert-out PATH --common-name TEXT
                      [--rsa-bits N] [--valid-days N]
                      [--not-after-limit UTC] [--format text|json]

Options#

--key-out <path>#

Required destination for the new CA private key. The destination must not exist.

--cert-out <path>#

Required destination for the new CA certificate. The destination must not exist.

--common-name <text>#

Required name for the CA, such as Example Service CA. This name is stored in the certificate’s Common Name (CN) field.

--rsa-bits <n>#

RSA key size in bits. The default is 3072. The minimum is 2048.

--valid-days <n>#

Requested certificate lifetime in days. The value must be a positive integer. The default is 1825.

--not-after-limit <utc>#

Optional expiration deadline in UTC. If the lifetime requested with --valid-days would extend past this date, the command shortens it and reports the change. Creation fails if no valid lifetime remains.

See Common Options for --format and --help.

Examples#

Create a CA named Example Service CA, saving its key and certificate in an existing private directory named pki:

dioptra-ssl create-ca --key-out pki/ca.key --cert-out pki/ca.crt \
  --common-name "Example Service CA"

issue#

Creates an RSA private key and a server certificate signed by the CA you specify. It signs the certificate with SHA-256 using the CA’s RSA or ECDSA private key. The certificate includes the DNS names and IP addresses supplied with --dns and --ip.

Syntax#

dioptra-ssl issue --ca-cert PATH --ca-key PATH --key-out PATH --cert-out PATH
                  [--dns NAME]... [--ip ADDRESS]... [--ca-chain PATH]
                  [--rsa-bits N] [--valid-days N] [--not-after-limit UTC]
                  [--issuance-log PATH] [--format text|json]

At least one --dns or --ip is required. These names and addresses are stored in the certificate’s Subject Alternative Name (SAN) extension.

Options#

--ca-cert <path>#

Required PEM certificate for the signing CA. The certificate must be valid and permit certificate signing.

--ca-key <path>#

Required private key for the signing CA. The key must match the certificate supplied with --ca-cert.

--ca-chain <path>#

Optional PEM file containing intermediate CA certificates needed to complete the certificate chain. Omit this option when using a CA created by create-ca.

--key-out <path>#

Required destination for the new server private key. The destination must not exist.

--cert-out <path>#

Required destination for the new server certificate. The destination must not exist.

--dns <name>#

Add a DNS name clients use to connect to the server. Repeat this option for additional names.

--ip <address>#

Add an IPv4 or IPv6 address clients use to connect to the server. Repeat this option for additional addresses.

--rsa-bits <n>#

New server key size in bits. The default is 3072. The minimum is 2048.

--valid-days <n>#

Requested certificate lifetime in days. The value must be a positive integer. The default is 365.

The command shortens the lifetime if necessary so the certificate expires no later than the CA certificate or the deadline set by --not-after-limit. It reports any shortening and fails if no valid lifetime remains.

--not-after-limit <utc>#

Optional expiration deadline in UTC.

--issuance-log <path>#

Optional path to a log of certificates signed by this command. No log is written by default. See Optional Issuance History for the file format and logging behavior.

See Common Options for --format and --help.

Examples#

Issue a certificate for service.example.org and 192.0.2.20 using the CA in the existing pki directory:

dioptra-ssl issue --ca-cert pki/ca.crt --ca-key pki/ca.key \
  --key-out pki/service.key --cert-out pki/service.crt \
  --dns service.example.org --ip 192.0.2.20

validate#

Checks local certificate files without changing them.

For server certificates, it verifies the certificate chain against root CA certificates you supply and checks the requested DNS names and IP addresses. With --kind ca, it checks whether a CA certificate can sign other certificates.

If you supply a private key, it also checks that the key matches the certificate.

The command does not connect to a running server or check whether certificates have been revoked. See Algorithms for supported certificate keys and signature algorithms.

Syntax#

dioptra-ssl validate --cert PATH [--key PATH] [--kind server|ca|outbound-ca]
                     [--trust PATH]... [--dns NAME]... [--ip ADDRESS]...
                     [--max-not-after UTC] [--warn-ca-not-after UTC]
                     [--format text|json]

By default, the command validates a server certificate. This requires --trust and at least one --dns or --ip.

Options#

--cert <path>#

Required path to a PEM certificate file. For server validation, this single file must contain the server certificate first, followed by any required intermediate certificates. Supply root CA certificates separately with --trust.

--key <path>#

Optional path to a private key file. The command checks that this key matches the certificate.

--kind <server|ca|outbound-ca>#

Certificate type to validate. The default is server.

server

Check a server certificate’s chain and the requested DNS names and IP addresses.

ca

Check whether a CA certificate is valid for signing other certificates. No DNS name or IP address is required.

outbound-ca

Inspect one CA certificate used to access external websites, reporting policy problems as warnings. Use --cert to supply the certificate; --warn-ca-not-after and --format are optional.

--trust <path>#

Path to a PEM file containing a root CA certificate to trust for this check. Required for server certificate validation. Repeat this option to supply additional root CA files.

--dns <name>#

Check that the server certificate is valid for the specified DNS name. Repeat this option to check additional names.

--ip <address>#

Check that the server certificate is valid for the specified IPv4 or IPv6 address. Repeat this option to check additional addresses.

--max-not-after <utc>#

Optional expiration deadline in UTC for the certificate supplied with --cert. Validation fails if that certificate expires after this date.

--warn-ca-not-after <utc>#

Optional expiration threshold in UTC for CA certificates in the chain. A CA certificate that expires after this date produces a warning. The warning alone does not cause validation to fail.

With --kind server or --kind ca, certificates must be within their validity period and use supported algorithms, whether or not these options are supplied.

See Common Options for --format and --help.

Examples#

Validate a server certificate for service.example.org and check its private key, using root-ca.crt as the trusted root CA:

dioptra-ssl validate --cert server-chain.pem --key server.key \
  --trust root-ca.crt --dns service.example.org

Validate a CA certificate and check that its private key matches:

dioptra-ssl validate --kind ca --cert pki/ca.crt --key pki/ca.key

Output and Exit Status#

Results report certificate details, checks and warnings as applicable to the command. JSON output also includes a schema version and the command name.

Successful commands return exit status 0. Errors identify the affected file or certificate and the failed operation or check. File-access and storage errors include the operating-system reason. Errors are written to standard error and return a nonzero exit status. In JSON mode, an error is reported as a single structured JSON object.

Argument Values#

  • Relative file paths are resolved from the directory where you run the command.

  • Dates and times use UTC in RFC 3339 format, ending in Z, for example 2030-12-31T23:59:59Z.

  • DNS names and IP addresses must not include a URL scheme or port number. For example, use dioptra.example.org, not https://dioptra.example.org:443.

Files and Permissions#

Created file

Format

Permissions

Certificate

PEM

0644

Private key

Unencrypted PKCS#8 PEM

0600

Create output files in directories you own. Store private keys and their backups in directories only you can access, outside source control.

Creation Failures and Retained Files#

create-ca and issue fail if either output file already exists. If a command fails while writing the files, it reports which files were written and the paths to the saved certificate and private key. If issuance logging was requested, it also reports whether the issuance record was saved successfully. Keep these saved files until recovery is complete. Follow Recover from Interrupted Certificate Creation to restore an intact pair or generate replacements. If a requested issuance record cannot be confirmed, you can recover a validated pair while accepting that the issuance might not be recorded. If you require a complete record, generate a new pair with working logging.

For certificates managed by a Dioptra deployment, see Recover an Interrupted Certificate Operation.

Recovery Problems#

The following cases cover validation and file errors during standalone recovery. For the restart procedure, follow Start Again in the certificate recovery how-to.

Problem

Action

A file cannot be read or written, or its permissions cannot be set.

Check the reported path, that its parent directory exists, and that you own the output directory and have the required access. Correct the path or use a private directory you own. For a read-only filesystem, use a writable location.

Storage is full or a filesystem operation fails.

Free space or use a working filesystem with sufficient space, then start again with unused output paths. A failed write may leave a partial file.

A certificate or key is malformed, missing, or does not match its partner.

Check that both saved files belong to the same attempt. If they remain unusable, start again. Restore damaged externally supplied files from a known-good copy or obtain replacements from their provider; a lost private key can require a new certificate.

The server certificate’s chain cannot be verified.

Check the root CA supplied with --trust and the intermediate certificates in the certificate file. If the correct inputs still fail validation, start again using a valid signing CA and its matching key.

A DNS name or IP address does not match.

Check the validation argument against the original issuance request. If the certificate lacks a name you need, issue a new certificate with that name.

A certificate is outside its validity period or exceeds the requested deadline.

Check the system clock and compare any --max-not-after argument with the original request. If the saved certificate still fails the validity check, generate a replacement using a valid CA.

An algorithm is unsupported or a CA cannot be used for signing.

Check that you selected the intended certificate. If so, use a CA and certificate that meet the supported requirements.

An existing output’s checksum differs from its saved copy.

Check the selected paths. If they are correct, leave both files unchanged and start again with unused output paths.

Keep saved files and existing outputs when starting again. A failed server-certificate operation does not require replacing a healthy CA.

Optional Issuance History#

Use issue --issuance-log PATH to record certificate signing in the specified file. The file uses UTF-8 JSON Lines format, with one JSON object per line, and permissions 0600. Each record contains:

  • A schema version and unique issuance ID.

  • The signing time in UTC.

  • SHA-256 fingerprints of the signing CA certificate and the issued certificate.

  • The issued certificate’s serial number, DNS names, IP addresses and validity dates.

  • The public-key and signature algorithms.

The issued certificate’s fingerprint and issuance ID identify its log record. The log covers only signing performed by this command with logging enabled. An interruption between signing and writing the log can leave a signed certificate without a log record.

Logging failures#

Condition

Result

The log cannot be written.

The command fails and saves the generated certificate and private key for recovery.

The log is written, but writing the certificate or key output fails.

The log record remains. It confirms signing, but does not confirm that both output files were written successfully.

The log contains an invalid or incomplete record.

The command stops before signing another certificate. Keep the log unchanged and select a new log path when starting a fresh issuance.

For subsequent issuance, you can reuse a valid, writable log. If the log is damaged or its condition is uncertain, select a new, unused path with --issuance-log and retain the old log. The new log records subsequent issuance; it does not record a recovered certificate retrospectively or complete the old history. Missing or damaged records are not reconstructed as part of recovery. A complete record remains part of the signing history even if its certificate will not be used.

To start a fresh issuance, follow Start Again in the certificate recovery how-to. See Creation Failures and Retained Files for failure reporting.

See Also#