Certificates¶
Include: Use System\Security.pkg
See Also: DFSEC_CertificateFromFile, DFSEC_CertificateFromString, DFSEC_CertificateFree, cHttpClient.ClientCertificate
Purpose¶
Provides certificate handles that can be assigned to APIs such as cHttpClient.ClientCertificate.
Constants¶
C_DFSEC_CERTFORMAT_PEM
: PEM certificate text.
C_DFSEC_CERTFORMAT_P12
: PKCS#12/P12 certificate data.
DFSEC_CERTFORMAT
: Integer-backed DataFlex format type used by the certificate APIs.
Behavior¶
Create a certificate handle with DFSEC_CertificateFromFile or DFSEC_CertificateFromString. A successful call returns a nonzero handle. A failed call returns 0.
When assigning a handle to a consuming API, keep the handle valid while the consumer may use it. For cHttpClient, clear ClientCertificate before freeing a handle that was assigned to the object.
Free nonzero certificate handles with DFSEC_CertificateFree when they are no longer needed.
Certificate parsing is not supported on web/WASI runtime paths. Certificate creation returns 0 on those platforms; the DataFlex tests skip certificate creation when RuntimePlatformIsWeb() is true.
Example¶
Handle hoCert hoHttp
Get DFSEC_CertificateFromFile C_DFSEC_CERTFORMAT_PEM "client.pem" "client-key.pem" "" to hoCert
If (hoCert <> 0) Begin
Object oHttp is a cHttpClient
Move Self to hoHttp
End_Object
Set ClientCertificate of hoHttp to hoCert
// Use hoHttp here.
Set ClientCertificate of hoHttp to 0
Send DFSEC_CertificateFree hoCert
End