POST Certificates Download

The POST /Certificates/Download operation downloads a certificate from Keyfactor Command. On success, the operation returns HTTP 200 OK with  the base-64-encoded certificate without private keyClosed Private keys are used in cryptography (symmetric and asymmetric) to encrypt or sign content. In asymmetric cryptography, they are used together in a key pair with a public key. The private or secret key is retained by the key's creator, making it highly secure., including optional certificate chain, in DERClosed A DER format certificate file is a DER-encoded binary certificate. It contains a single certificate and does not support storage of private keys. It sometimes has an extension of .der but is often seen with .cer or .crt., PEMClosed A PEM format certificate file is a Base64-encoded certificate. Since it's presented in ASCII, you can open it in any text editor. PEM certificates always begin and end with entries like ---- BEGIN CERTIFICATE---- and ----END CERTIFICATE----. PEM certificates can contain a single certificate or a full certificate chain and may contain a private key. In general, extensions of .cer and .crt are certificate files with no private key, .key is a separate private key file, and .pem is both a certificate and private key. of P7BClosed A PKCS #7 format certificate file is a Base64-encoded certificate. Since it's presented in ASCII, you can open it in any text editor. PKCS #7 certificates always begin and end with entries that look something like ---- BEGIN CERTIFICATE---- and ----END CERTIFICATE----. Unlike PEM files, PKCS #7 files can contain only a certificate and its certificate chain but NOT its private key. Extensions of .p7b or .p7c are usually seen on certificate files of this format. format. For certificates with private keys in PEM or PFXClosed A PFX file (personal information exchange format), also known as a PKCS #12 archive, is a single, password-protected certificate archive that contains both the public and matching private key and, optionally, the certificate chain. It is a common format for Windows servers. format, use the POST Certificates Recover operation.

Tip:  The following permissions (see Security Roles and Claims) are required to use this feature:
/certificates/collections/read/
OR
/certificates/collections/read/#/
OR
/certificate_stores/read/
OR
/certificate_stores/read/#/

Permissions for certificates can be set at the system-wide or resource-specific level. The appropriate level depends on how the certificates are accessed. See Certificate CollectionClosed The certificate search function allows you to query the Keyfactor Command database for certificates from any available source based on any criteria of the certificates and save the results as a collection that will be available in other places in the Management Portal (for example expiration alerts and certain reports). Permissions and Application Permissions for more information.

In permission strings, # represents a specific resource identifier. In /certificates/collections/ permission strings it refers to a certificate collection ID (for example, CollectionId) and in /certificate_stores/ permission strings it refers to a certificate store application ID (for example, containerId).

Table 319: POST Certificates Download Input Parameters

Name In

Description

CertID Body

Required in some cases.  An integer indicating the Keyfactor Command reference ID of the certificate to retrieve.

One of the following is required:

  • CertID
  • Thumbprint

  • SerialNumber and IssuerDN

ChainOrder Body A string indicating the order in which the certificate chain should be returned if IncludeChain is set to True. Supported values are EndEntityFirst or RootFirst.
CollectionId Query

An optional integer that specifies the certificate collection (CollectionId) to validate whether the user has sufficient permissions to perform the action. If a CollectionId is not provided, the user must have appropriate permissions granted system-wide or via certificate store applications.

Providing a CollectionId allows the system to check the user's permissions at the certificate collection level. Permissions are evaluated in the following order:

  1. System-wide certificate permissions
  2. Granular certificate permissions

Use either ContainerId or CollectionId, not both. If both are specified, CollectionId takes precedence, and the ContainerId is ignored (defaults to 0).

See Certificate Collection Permissions for more information.

ContainerId Query

An optional integer that specifies the certificate store application (ContainerId) to validate whether the user has sufficient permissions to perform the action. If a ContainerId is not provided, the user must have appropriate permissions granted system-wide or via certificate collections.

Providing a ContainerId allows the system to check the user's permissions at the application level. Permissions are evaluated in the following order:

  1. System-wide certificate store application permissions
  2. Granular certificate store application permissions

Use either ContainerId or CollectionId, not both. If both are specified, CollectionId takes precedence, and the ContainerId is ignored (defaults to 0).

See Application Permissions for more information.

File Extension Body

A string indicating the desired file extension to use for the certificate. See also x-CertificateFormat for the desired file type. Supported values are:

  • CER: Compatible with certificate format CER, DER or PEM.
  • CRT: Compatible with certificate format CRT, DER or PEM.
  • PEM: Compatible with certificate format PEM.
  • P7B: Compatible with certificate format P7B.

The default value is based on the specified certificate format as follows:

  • Certificate format CER = File extension CER
  • Certificate format CRT = File extension CRT
  • Certificate format DER = File extension CER
  • Certificate format P7B = File extension P7B
  • Certificate format PEM = File extension PEM
IncludeChain Body

A Boolean indicating whether to include the certificate chain with the certificate (True or False). If you select True, you must select a certificate format of P7B or PEM in the request header. The option will be ignored and set to False for all other formats. The default is False.

Note:  Certificate chains for end-entity certificate download are constructed using the following methods, in order of priority:
  1. Trust Bundles: Keyfactor Command first attempts to build the chain using only the root certificates contained in configured trust bundles (see Trust Bundles).
  2. AIA Retrieval: If the chain cannot be build using trust bundles, Keyfactor Command attempts to retrieve issuer certificates using the AIA (Authority Information Access) extension, if present. Only HTTP and HTTPS AIA URLs are supported, and the certificates must be accessible from the Keyfactor Command server.
  3. Trusted Certificate Stores (Windows only): If the above methods fail, Keyfactor Command attempts to complete the chain using certificates in the server’s local machine Trusted Root Certification Authorities and Intermediate Certification Authorities stores.
IssuerDN Body

Required in some cases.  A string indicating the distinguished name of the issuer of the certificate to retrieve.

One of the following is required:

  • CertID
  • Thumbprint

  • SerialNumber and IssuerDN

Include Subject Header Body

A Boolean that sets whether to include the subject header in the response (True or False). The default is True.

Applies only when PEM format is selected. When set to False, the subject header line is removed from the PEM output. When set to True,the subject header line is included.

When IncludeChain is set to True, this setting applies to each certificate in the returned chain. It also applies when the private key is included.

Microsoft Target CSP Body A string indicating the optional cryptographic service provider (CSP) to associate with the certificate in the Public Key Cryptography Standard #12 (PKCS #12) key provider name attribute (OID 1.3.6.1.4.1.311.17.1). A value should only be provided here if the Enrollment > General > Allow Cryptographic Service Providers (CSPs) application setting has been enabled and only values included in the Enrollment > General > Cryptographic Service Providers (CSPs) application setting list are valid for this value (see Application Settings: Enrollment Tab).
RootCertificateId Body

An integer specifying the Keyfactor Command reference ID of the root certificate to use when building the certificate chain for the downloaded certificate. The root certificate must be contained in a configured trust bundle. If this value is not specified, Keyfactor Command builds the chain using the standard certificate chain building methods.

Note:  Certificate chains for end-entity certificate download are constructed using the following methods, in order of priority:
  1. Trust Bundles: Keyfactor Command first attempts to build the chain using only the root certificates contained in configured trust bundles (see Trust Bundles).
  2. AIA Retrieval: If the chain cannot be build using trust bundles, Keyfactor Command attempts to retrieve issuer certificates using the AIA (Authority Information Access) extension, if present. Only HTTP and HTTPS AIA URLs are supported, and the certificates must be accessible from the Keyfactor Command server.
  3. Trusted Certificate Stores (Windows only): If the above methods fail, Keyfactor Command attempts to complete the chain using certificates in the server’s local machine Trusted Root Certification Authorities and Intermediate Certification Authorities stores.
SerialNumber Body

Required in some cases.  A string indicating the serial number of the certificate to retrieve.

One of the following is required:

  • CertID
  • Thumbprint

  • SerialNumber and IssuerDN

Thumbprint Body

Required in some cases.  A string indicating the thumbprint of the certificate to retrieve.

One of the following is required:

  • CertID

  • Thumbprint

  • SerialNumber and IssuerDN

x-certificateformat Header

The desired output format for the certificate. Supported options are:

  • CER

    Output the certificate in Base64-encoded PEM format along with any optional chain certificates in a single file.

  • CRT

    Output the certificate in Base64-encoded PEM format along with any optional chain certificates in a single file.

  • DER

    Output the certificate in DER-encoded format. DER is not supported if IncludeChain is set to True.

  • PEM

    Output the certificate in Base64-encoded PEM format along with any optional chain certificates in a single file.

  • P7B

    This option is only supported if IncludeChain is set to True

Table 320: POST Certificates Download Response Data

Name

In

Description
Content Content The Base64-encoded certificate in DER, PEM or P7B format with the optional certificate chain.
X-CertificateFile Headers A string containing the file name assigned for the certificate. The file name is constructed from the Subject CN and the FileExtension or default extension based on the specified x-CertificateFormat and is affected by the Allow Periods in Certificate Filenames application setting (see Application Settings: Enrollment Tab).