DFSEC_CertificateFromFile¶
Include: Use System\Security.pkg
See Also: Certificates, DFSEC_CertificateFromString, DFSEC_CertificateFree
Purpose¶
Creates a certificate handle from certificate data stored in files.
Syntax¶
Function DFSEC_CertificateFromFile Global DFSEC_CERTFORMAT eFormat String sCertificateFile String sOptKeyFile String sOptPassword Returns Handle
Arguments¶
eFormat
: Certificate format. Use C_DFSEC_CERTFORMAT_PEM or C_DFSEC_CERTFORMAT_P12.
sCertificateFile
: Path to the certificate file to read.
sOptKeyFile
: Optional path to a private key file. For PEM certificates, this may provide the private key. For P12 data, this is normally empty.
sOptPassword
: Optional password. For PEM certificates, this may unlock the private key. For P12 data, this may unlock the bundle.
Returns¶
A nonzero certificate handle on success, or 0 when no certificate handle could be created.
Behavior¶
DFSEC_CertificateFromFile reads certificate bytes from sCertificateFile and creates a handle for the requested format.
It returns 0 for an unsupported format, missing or unreadable files, empty certificate data, invalid certificate data, a password/key mismatch, or an unsupported platform.
Free nonzero handles with DFSEC_CertificateFree when finished.
Example¶
Handle hCertificate hoHttp
Get DFSEC_CertificateFromFile C_DFSEC_CERTFORMAT_PEM "client.pem" "client-key.pem" "" to hCertificate
If (hCertificate <> 0) Begin
Object oHttp is a cHttpClient
Move Self to hoHttp
End_Object
Set ClientCertificate of hoHttp to hCertificate
// Use hoHttp here.
Set ClientCertificate of hoHttp to 0
Send DFSEC_CertificateFree hCertificate
End