(PowerBuilder) Get Certificate's Public Key
Loads a certificate from PEM and gets the public key.
integer li_rc
oleobject loo_Cert
string ls_StrPem
integer li_Success
oleobject loo_PubKey
loo_Cert = create oleobject
// Use "Chilkat_9_5_0.Cert" for versions of Chilkat < 10.0.0
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
ls_StrPem = "-----BEGIN CERTIFICATE----- ..."
li_Success = loo_Cert.LoadPem(ls_StrPem)
if li_Success <> 1 then
Write-Debug loo_Cert.LastErrorText
destroy loo_Cert
return
end if
loo_PubKey = loo_Cert.ExportPublicKey()
if loo_Cert.LastMethodSuccess = 0 then
Write-Debug loo_Cert.LastErrorText
destroy loo_Cert
return
end if
// You can now use the public key object however it is needed,
// and access its various properties and methods..
Write-Debug loo_PubKey.GetXml()
destroy loo_PubKey
destroy loo_Cert
|