ExportCertificate Method
Saves the current certificate to a file.
Syntax
int ExportCertificate(char* lpszCertFile, char* lpszPassword);
Remarks
This method will save the current certificate to a file. The current certificate and its private key are saved to the file specified by CertFile in the specified format. The file contents are protected by Password.
In the Unix edition, the current certificate and its private key are saved to the file specified by PFXFile in PEM format. The private key is encrypted using the Password.
By default when ExportCertificate is called the certificate will be written as a PFX file. The format of the exported certificate may be changed by setting ExportFormat to one of the following values:
"PFX" or "PKCS12" (default) | A PFX file (PKCS12). |
"PEM" or "PKCS1" | A PEM formatted PKCS1 private key file. Example:
-----BEGIN RSA PRIVATE KEY----- MIICWwIBAAKBgQD5/STHUd7YkN1JyoyYnUvCf+Fyx1+ZleBJxvwDcm3yaZ98bvry ... 91y8ydb3mQ9l1hZudo2sj8tHnvEgph0r7B8hMM6Qaw== -----END RSA PRIVATE KEY----- |
"PKCS8" | A PEM formatted PKCS8 private key file. Example:
-----BEGIN PRIVATE KEY----- MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAPn9JMdR3tiQ3UnK ... HSvsHyEwzpBr -----END PRIVATE KEY----- |
"OpenSSHPrivateKey" | An OpenSSH private key file. Example:
-----BEGIN OPENSSH PRIVATE KEY----- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAlwAAAAdzc2gtcnNh ... AwQFBgcICQo= -----END OPENSSH PRIVATE KEY----- |
"PPK" | A PuTTY private key file. Example:
PuTTY-User-Key-File-2: ssh-rsa Encryption: none Comment: rsa-key-20180822 Public-Lines: 4 AAAAB3NzaC1yc2EAAAADAQABAAAAgQCmz5j5kWUKxfwiv6J0LQ4wN9ekpeORXVaP ... 8pSSWejQ5Q== Private-Lines: 8 AAAAgH87Sp/YcSw1dKoAZuWb0/2dKkKwMRIYEkS15caRpzAteay6WWX7l1sgBTU7 ... Oa0= Private-MAC: d53e24f44bde8d1d3844a142fbb1fa7c88ea3585 |
"JWK" | A JWK that contains a private key. |
Note: On Linux/Unix the PFX/PKCS12 format is not supported. On Unix/Linux the default format is "PEM".
Note: ExportCertificate is not support on macOS.
If CertFile is empty the certificate will be exported to a string accessible via the ExportedCert configuration setting.