PowerBuilder
PowerBuilder
Export a Private Key as XML
See more Private Key Examples
Demonstrates the Chilkat PrivateKey.GetXml method, which exports the key in Chilkat-compatible XML (for example an RSAKeyValue element). It takes no arguments; the XML is not encrypted.
Note: The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.
Background: The XML key format belongs to the .NET/XML-DSIG world, where keys are represented as XML elements. Exporting to it is what you do to hand a key to .NET code or a system built around XML signatures — the inverse of
LoadXml. It is plaintext, so the exported XML must be protected like any unencrypted key.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_PrivKey
string ls_Xml
li_Success = 0
// Load a private key to export.
loo_PrivKey = create oleobject
li_rc = loo_PrivKey.ConnectToNewObject("Chilkat.PrivateKey")
if li_rc < 0 then
destroy loo_PrivKey
MessageBox("Error","Connecting to COM object failed")
return
end if
li_Success = loo_PrivKey.LoadPemFile("qa_data/private.pem")
if li_Success = 0 then
Write-Debug loo_PrivKey.LastErrorText
destroy loo_PrivKey
return
end if
// Export in Chilkat-compatible XML (for example an RSAKeyValue element). The XML is not
// encrypted.
ls_Xml = loo_PrivKey.GetXml()
if loo_PrivKey.LastMethodSuccess = 0 then
Write-Debug loo_PrivKey.LastErrorText
destroy loo_PrivKey
return
end if
Write-Debug ls_Xml
destroy loo_PrivKey