PowerBuilder
PowerBuilder
ZATCA Load Certificate and Private Key from PEM Files
See more ZATCA Examples
Demonstrates how to load a certificate and private key from a pair of PEM files.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Cert
oleobject loo_PrivKey
li_Success = 0
// The LoadFromFile method will automatically detect the file format..
loo_Cert = create oleobject
li_rc = loo_Cert.ConnectToNewObject("Chilkat.Cert")
if li_rc < 0 then
destroy loo_Cert
MessageBox("Error","Connecting to COM object failed")
return
end if
li_Success = loo_Cert.LoadFromFile("qa_data/zatca/cert.pem")
if li_Success <> 1 then
Write-Debug loo_Cert.LastErrorText
destroy loo_Cert
return
end if
Write-Debug loo_Cert.SubjectCN
// Load the private key.
loo_PrivKey = create oleobject
li_rc = loo_PrivKey.ConnectToNewObject("Chilkat.PrivateKey")
li_Success = loo_PrivKey.LoadPemFile("qa_data/zatca/ec-secp256k1-priv-key.pem")
if li_Success <> 1 then
Write-Debug loo_PrivKey.LastErrorText
destroy loo_Cert
destroy loo_PrivKey
return
end if
Write-Debug "Key Type: " + loo_PrivKey.KeyType
// Associate the private key with the certificate.
li_Success = loo_Cert.SetPrivateKey(loo_PrivKey)
if li_Success <> 1 then
Write-Debug loo_Cert.LastErrorText
destroy loo_Cert
destroy loo_PrivKey
return
end if
Write-Debug "Success."
destroy loo_Cert
destroy loo_PrivKey