The CertificateManager component supports importing, exporting, and generating X.509 certificates.
Usage of this component includes importing and exporting certificates and keys in various formats, as well as certificate generation.
Loading certificatesIn vast majority of SecureBlackbox-powered projects, this component is used to import certificates from files or memory objects for further use in other components, like PDFSigner.
To load a certificate from a file, use the ImportFromFile method. This method supports all existing certificate formats, including PFX, PEM, DER, and P7B. Note that keys contained in PFX and PEM certificates are often encrypted with a password, so you will likely need to provide one for the certificate to be loaded correctly. You can either provide the password via the method's parameter, or provide it on-demand by subscribing to the PasswordNeeded event.
Alternatively, you can use ImportCert to load a certificate from a different type of media, such as a database.
If your certificate and its private key are stored in separate files or buffers - which is often the case where PEM or DER format is used - please load the certificate with the ImportFromFile method first, and then add the key to it with a separate call to the ImportKeyFromFile method. You can mix and match the certificate and key formats in this case; CertificateManager will handle this automatically.
Note that CertificateManager can only keep one certificate at a time. If your PFX or PEM file contains more than one certificate, use CertificateStorage component to load it instead.
Generating certificatesYou can use CertificateManager to generate your own certificates. To generate a certificate, please follow the below steps:
- set all the needed certificate properties - for example, its subject, serial number, and validity period - via the Certificate property.
- load the CA certificate to a different CertificateManager object, and assign it
to the CACertificate property. Note that the CA certificate should have an associated private key. Alternatively,
the CA certificate can be loaded using a CertificateStorage object, which allows to import it from a hardware device
or a system store.
Note: you do not need to load and set the CA certificate if generating a self-signed certificate.
- Call Generate to generate a new keypair and wrap it into a certificate.
- Save the certificate using ExportToFile or ExportCert methods.
Note: take care to choose a format that supports storing private keys. If you do not save the new private key at this stage, you won't be able to recover it later.
Note: you can save the private key separately using the ExportKey method.
Generating certificate requestsApart from certificates, CertificateManager can generate certificate requests (PKCS10). The procedure is the same as when generating certificates. The only difference is that you need to use CertificateRequest object to set up the certificate request parameters, and GenerateCSR method to generate the request. You can then save the resulting request to a file using the ExportCSR method.
The following is the full list of the properties of the component with short descriptions. Click on the links for further details.
|CACertificate||A container for the CA certificate.|
|Certificate||A container for the certificate object.|
|CertificateRequest||A container for the certificate request object.|
|ExternalCrypto||Provides access to external signing and DC parameters.|
The following is the full list of the methods of the component with short descriptions. Click on the links for further details.
|Config||Sets or retrieves a configuration setting.|
|Download||Downloads a certificate from a remote location.|
|ExportCert||Exports the certificate in the chosen format.|
|ExportCSR||Exports a Certificate Signing Request (CSR).|
|ExportKey||Exports the certificate's private key.|
|ExportKeyToFile||Exports the private key to a file in the chosen format.|
|ExportKeyToStream||Saves the private key to a stream.|
|ExportToFile||Exports the certificate to a file.|
|ExportToStream||Exports the certificate to a stream.|
|Generate||Generates a new certificate.|
|GenerateAsyncBegin||Initiates asynchronous (DC) certificate generation.|
|GenerateAsyncEnd||Completes asynchronous certificate generation.|
|GenerateCSR||Creates a new certificate signing request (CSR).|
|GenerateExternal||Generates a new certificate with an external signing device.|
|GetSampleCert||Generates a sample certificate for the specified purpose.|
|ImportCert||Imports a certificate.|
|ImportFromFile||Loads a certificate from a file.|
|ImportFromStream||Loads a certificate from a stream.|
|ImportKey||Imports a private key.|
|ImportKeyFromFile||Imports a private key from a file.|
|ImportKeyFromStream||Imports a private key from a stream.|
|Update||Renews the certificate.|
|Validate||Validates the certificate.|
The following is the full list of the events fired by the component with short descriptions. Click on the links for further details.
|Error||Information about errors during certificate loading, saving or validation.|
|ExternalSign||Handles remote or external signing initiated by the SignExternal method or other source.|
|Notification||This event notifies the application about an underlying control flow event.|
|PasswordNeeded||This event is fired when a decryption password is needed.|
The following is a list of configuration settings for the component with short descriptions. Click on the links for further details.
|KeyExchangePIN||The KeyExchange PIN to provide to the key in runtime.|
|SignaturePIN||The Signature PIN to provide to the key in runtime.|
|TempPath||Path for storing temporary files.|
|CheckKeyIntegrityBeforeUse||Enables or disable private key integrity check before use.|
|CookieCaching||Specifies whether a cookie cache should be used for HTTP(S) transports.|
|Cookies||Gets or sets local cookies for the component (supported for HTTPClient, RESTClient and SOAPClient only).|
|DefDeriveKeyIterations||Specifies the default key derivation algorithm iteration count.|
|EnableClientSideSSLFFDHE||Enables or disables finite field DHE key exchange support in TLS clients.|
|GlobalCookies||Gets or sets global cookies for all the HTTP transports.|
|HttpUserAgent||Specifies the user agent name to be used by all HTTP clients.|
|LogDestination||Specifies the debug log destination.|
|LogDetails||Specifies the debug log details to dump.|
|LogFile||Specifies the debug log filename.|
|LogFilters||Specifies the debug log filters.|
|LogFlushMode||Specifies the log flush mode.|
|LogLevel||Specifies the debug log level.|
|LogMaxEventCount||Specifies the maximum number of events to cache before further action is taken.|
|LogRotationMode||Specifies the log rotation mode.|
|MaxASN1BufferLength||Specifies the maximal allowed length for ASN.1 primitive tag data.|
|MaxASN1TreeDepth||Specifies the maximal depth for processed ASN.1 trees.|
|OCSPHashAlgorithm||Specifies the hash algorithm to be used to identify certificates in OCSP requests.|
|UseOwnDNSResolver||Specifies whether the client components should use own DNS resolver.|
|UseSharedSystemStorages||Specifies whether the validation engine should use a global per-process copy of the system certificate stores.|
|UseSystemOAEPAndPSS||Enforces or disables the use of system-driven RSA OAEP and PSS computations.|
|UseSystemRandom||Enables or disables the use of the OS PRNG.|