![]() |
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
(Lianja) 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.
llSuccess = .F. // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loHttp = createobject("CkHttp") // We're getting the SSL/TLS certificate, so make sure to connect to the SSL/TLS port (443). loSslCert = createobject("CkCert") llSuccess = loHttp.GetServerCert("apple.com",443,loSslCert) if (llSuccess = .F.) then ? loHttp.LastErrorText release loHttp release loSslCert return endif loCertChain = createobject("CkCertChain") llSuccess = loSslCert.BuildCertChain(loCertChain) if (llSuccess = .F.) then ? loSslCert.LastErrorText release loHttp release loSslCert release loCertChain return endif loCert = createobject("CkCert") i = 0 lnNumCerts = loCertChain.NumCerts do while i < lnNumCerts loCertChain.CertAt(i,loCert) ? "SubjectDN " + str(i) + ": " + loCert.SubjectDN ? "IssuerDN " + str(i) + ": " + loCert.IssuerDN i = i + 1 enddo // If the certificate chain reaches the root CA cert, then the last cert in the chain // is the root CA cert. if (loCertChain.ReachesRoot = .T.) then loCaCert = createobject("CkCert") loCertChain.CertAt(lnNumCerts - 1,loCaCert) ? "CA Root Cert: " + loCaCert.SubjectDN endif release loHttp release loSslCert release loCertChain release loCert release loCaCert |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.