![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PowerBuilder) Get the Server Certificate, Certificate Chain, and Root CA CertificateDemonstrates how to get the HTTP server certificate, its certificate chain, and the root CA certificate. Note: This example requires Chilkat v11.0.0 or greater.
integer li_rc integer li_Success oleobject loo_Http oleobject loo_SslCert oleobject loo_CertChain oleobject loo_Cert integer i integer li_NumCerts oleobject loo_CaCert li_Success = 0 // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Http = create oleobject li_rc = loo_Http.ConnectToNewObject("Chilkat.Http") if li_rc < 0 then destroy loo_Http MessageBox("Error","Connecting to COM object failed") return end if // We're getting the SSL/TLS certificate, so make sure to connect to the SSL/TLS port (443). loo_SslCert = create oleobject li_rc = loo_SslCert.ConnectToNewObject("Chilkat.Cert") li_Success = loo_Http.GetServerCert("apple.com",443,loo_SslCert) if li_Success = 0 then Write-Debug loo_Http.LastErrorText destroy loo_Http destroy loo_SslCert return end if loo_CertChain = create oleobject li_rc = loo_CertChain.ConnectToNewObject("Chilkat.CertChain") li_Success = loo_SslCert.BuildCertChain(loo_CertChain) if li_Success = 0 then Write-Debug loo_SslCert.LastErrorText destroy loo_Http destroy loo_SslCert destroy loo_CertChain return end if loo_Cert = create oleobject li_rc = loo_Cert.ConnectToNewObject("Chilkat.Cert") i = 0 li_NumCerts = loo_CertChain.NumCerts do while i < li_NumCerts loo_CertChain.CertAt(i,loo_Cert) Write-Debug "SubjectDN " + string(i) + ": " + loo_Cert.SubjectDN Write-Debug "IssuerDN " + string(i) + ": " + loo_Cert.IssuerDN i = i + 1 loop // If the certificate chain reaches the root CA cert, then the last cert in the chain // is the root CA cert. if loo_CertChain.ReachesRoot = 1 then loo_CaCert = create oleobject li_rc = loo_CaCert.ConnectToNewObject("Chilkat.Cert") loo_CertChain.CertAt(li_NumCerts - 1,loo_CaCert) Write-Debug "CA Root Cert: " + loo_CaCert.SubjectDN end if destroy loo_Http destroy loo_SslCert destroy loo_CertChain destroy loo_Cert destroy loo_CaCert |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.