Class PfxBuilder
Supports generating PFX from the certificate and key pair.
Inheritance
Namespace: Certes.Pkcs
Assembly: Certes.dll
Syntax
public class PfxBuilder
Remarks
This packages a certificate chain; it does not validate a certification path. Issuers are accepted only after verifying that they signed the certificate below them, but issuer constraints, revocation, and complete-path validity are not checked. The supplied private key is checked against the leaf certificate, but trust decisions belong to the relying party that consumes the PFX.
Constructors
| Edit this page View SourcePfxBuilder(byte[], IKey)
Initializes a new instance of the PfxBuilder class.
Declaration
public PfxBuilder(byte[] certificate, IKey privateKey)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | certificate | The certificate. |
| IKey | privateKey | The private key. |
PfxBuilder(byte[], KeyInfo)
Initializes a new instance of the PfxBuilder class.
Declaration
public PfxBuilder(byte[] certificate, KeyInfo privateKeyInfo)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | certificate | The certificate. |
| KeyInfo | privateKeyInfo | The private key information. |
Properties
| Edit this page View SourceEncryption
Gets or sets the algorithms used to protect the private key and certificates.
Declaration
public PfxEncryption Encryption { get; set; }
Property Value
| Type | Description |
|---|---|
| PfxEncryption | Defaults to Aes256. |
Remarks
The integrity check (MAC) uses HMAC-SHA1 in both modes; BouncyCastle does not expose another MAC algorithm. OpenSSL 3 and .NET accept it.
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | The value is not a defined PfxEncryption member. |
FullChain
Gets or sets a value indicating whether to include the full certificate chain in the PFX.
Declaration
public bool FullChain { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Remarks
The chain is the certificate followed by the issuers linked to it, excluding any self-signed root. It is not a validated certification path.
Methods
| Edit this page View SourceAddIssuer(byte[])
Adds an issuer certificate.
Declaration
public void AddIssuer(byte[] certificate)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | certificate | The issuer certificate. |
AddIssuers(byte[])
Adds issuer certificates.
Declaration
public void AddIssuers(byte[] certificates)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | certificates | The issuer certificates. |
Build(string, string)
Builds the PFX with specified friendly name.
Declaration
public byte[] Build(string friendlyName, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| string | friendlyName | The friendly name. |
| string | password | The password. |
Returns
| Type | Description |
|---|---|
| byte[] | The PFX data. |
Remarks
Verifies that the private key matches the leaf certificate, then packages the certificate and its linked issuers. No certification path validation is performed, so an expired or otherwise unusable certificate is exported as supplied.