Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

PowerBuilder Examples

Web API Categories

ASN.1
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
Geolocation
Google APIs
Google Calendar
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text

HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
REST
REST Misc
RSA
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(PowerBuilder) Examine KeyInfo Certificate in XML Signature

This example loads signed XML and gets the signing certificate, assuming the certificate is contained in X509Certificate within the KeyInfo.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

integer li_rc
oleobject loo_Dsig
oleobject loo_SbXml
integer li_Success
oleobject loo_XmlKeyInfo
string ls_CertBase64
oleobject loo_Cert

//  This example requires the Chilkat API to have been previously unlocked.
//  See Global Unlock Sample for sample code.

loo_Dsig = create oleobject
li_rc = loo_Dsig.ConnectToNewObject("Chilkat_9_5_0.XmlDSig")
if li_rc < 0 then
    destroy loo_Dsig
    MessageBox("Error","Connecting to COM object failed")
    return
end if
loo_SbXml = create oleobject
li_rc = loo_SbXml.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

li_Success = loo_SbXml.LoadFile("c:/aaworkarea/elias/3/face_f09006808443a699d1b.xml","utf-8")
if li_Success <> 1 then
    Write-Debug "Failed to load XML file."
    destroy loo_Dsig
    destroy loo_SbXml
    return
end if

li_Success = loo_Dsig.LoadSignatureSb(loo_SbXml)
if li_Success <> 1 then
    Write-Debug loo_Dsig.LastErrorText
    destroy loo_Dsig
    destroy loo_SbXml
    return
end if

//  Get the KeyInfo XML.
loo_XmlKeyInfo = loo_Dsig.GetKeyInfo()
if loo_Dsig.LastMethodSuccess <> 1 then
    Write-Debug loo_Dsig.LastErrorText
    destroy loo_Dsig
    destroy loo_SbXml
    return
end if

Write-Debug loo_XmlKeyInfo.GetXml()
Write-Debug "----"

//  Assuming the X509Certificate is in the KeyInfo, it will look like this:

//    <ds:KeyInfo Id="...">
//      <ds:KeyValue>
//      ...
//      <ds:X509Data>
//        <ds:X509Certificate>MIIHAz...</ds:X509Certificate>
//      </ds:X509Data>
//    </ds:KeyInfo>
ls_CertBase64 = loo_XmlKeyInfo.GetChildContent("*:X509Data|*:X509Certificate")
if loo_XmlKeyInfo.LastMethodSuccess <> 1 then
    Write-Debug "No X509Certificate found in the KeyInfo."
    destroy loo_Dsig
    destroy loo_SbXml
    return
end if

//  Load a certificate object w/ the base64.
loo_Cert = create oleobject
li_rc = loo_Cert.ConnectToNewObject("Chilkat_9_5_0.Cert")

li_Success = loo_Cert.LoadFromBase64(ls_CertBase64)
if li_Success <> 1 then
    Write-Debug loo_Cert.LastErrorText
    destroy loo_Dsig
    destroy loo_SbXml
    destroy loo_Cert
    return
end if

//  Examine the cert..
Write-Debug "SubjectDN: " + loo_Cert.SubjectDN
Write-Debug "IssuerDN: " + loo_Cert.IssuerDN
Write-Debug "SerialNumber as Decimal: " + loo_Cert.SerialDecimal

destroy loo_XmlKeyInfo


destroy loo_Dsig
destroy loo_SbXml
destroy loo_Cert

 

© 2000-2019 Chilkat Software, Inc. All Rights Reserved.