Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) Build Certificate Chain from Base64 CertificatesDemonstrates how to build a certificate chain from a set of base64 certificates. Note: This example requires v9.5.0.87 or greater to resolve an issue with the data used in this example.
Use ChilkatAx-win32.pkg Procedure Test String sCert1 String sCert2 String sCert3 String sCaRootCert Handle hoCert Boolean iSuccess Variant vCertVault Handle hoCertVault Variant vChain Handle hoChain Integer iNumCerts Integer i Variant vCertInChain Handle hoCertInChain String sTemp1 // We have the following certificates: // 1: tools.chilkat.io Move "MIIGdzCCBV+gAwIBAgIQah36/0eUf3vjWnJEqykBITANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEYMBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkMTcwNQYDVQQDEy5TZWN0aWdvIFJTQSBEb21haW4gVmFsaWRhdGlvbiBTZWN1cmUgU2VydmVyIENBMB4XDTE5MDkxMjAwMDAwMFoXDTIxMTAwOTIzNTk1OVowVDEhMB8GA1UECxMYRG9tYWluIENvbnRyb2wgVmFsaWRhdGVkMRQwEgYDVQQLEwtQb3NpdGl2ZVNTTDEZMBcGA1UEAxMQdG9vbHMuY2hpbGthdC5pbzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANdVgSFZbZzl7LehEGTmXLSOCagd+f6ullW5jv5Vi79OswJZXDJm4YV3eotbiSCAioqdkpgH+IqK+GTh1lcHR2GPg5H3qQZiRjLvGKZGSQinhtC3XoYp2Eoh7WDn4O8X9Kpj+vo2keExtp9vEpf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AyrL58OAd7vn5lJ8S3frHRNG5i1R8XlKdH5kBjHYpy+g8cmez6KJcfA3Z3mNWgQIJ2P2N7Sw4ScDV7oL8kCAwEAAaOBwDCBvTAdBgNVHQ4EFgQUoBEKIz6W8Qfs4q8p74Klf9AwpLQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wewYDVR0fBHQwcjA4oDagNIYyaHR0cDovL2NybC5jb21vZG9jYS5jb20vQUFBQ2VydGlmaWNhdGVTZXJ2aWNlcy5jcmwwNqA0oDKGMGh0dHA6Ly9jcmwuY29tb2RvLm5ldC9BQUFDZXJ0aWZpY2F0ZVNlcnZpY2VzLmNybDANBgkqhkiG9w0BAQUFAAOCAQEACFb8AvCb6P+k+tZ7xkSAzk/ExfYAWMymtrwUSWgEdujm7l3sAg9g1o1QGE8mTgHj5rCl7r+8dFRBv/38ErjHT1r0iWAFf2C3BUrz9vHCv8S5dIa2LX1rzNLzRt0vxuBqw8M0Ayx9lt1awg6nCpnBBYurDC/zXDrPbDdVCYfeU0BsWO/8tqtlbgT2G9w84FoVxp7Z8VlIMCFlA2zs6SFz7JsDoeA3raAVGI/6ugLOpyypEBMs1OUIJqsil2D4kF501KKaU73yqWjgom7C12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg==" To sCaRootCert Get Create (RefClass(cComChilkatCert)) To hoCert If (Not(IsComObjectCreated(hoCert))) Begin Send CreateComObject of hoCert End // Load our main certificate.. Get ComLoadFromBase64 Of hoCert sCert1 To iSuccess // Load the issuer certs in the chain into a Chilkat cert vault. // Order doesn't matter. Get Create (RefClass(cComChilkatXmlCertVault)) To hoCertVault If (Not(IsComObjectCreated(hoCertVault))) Begin Send CreateComObject of hoCertVault End Get ComAddCertEncoded Of hoCertVault sCert2 "base64" To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoCertVault To sTemp1 Showln sTemp1 Procedure_Return End Get ComAddCertEncoded Of hoCertVault sCert3 "base64" To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoCertVault To sTemp1 Showln sTemp1 Procedure_Return End Get ComAddCertEncoded Of hoCertVault sCaRootCert "base64" To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoCertVault To sTemp1 Showln sTemp1 Procedure_Return End // Provide the certVault to the cert as a source for finding issuers to build a cert chain. Get pvComObject of hoCertVault to vCertVault Get ComUseCertVault Of hoCert vCertVault To iSuccess // We can now build the cert chain and get the certs in the chain of authentication (in order) Get ComGetCertChain Of hoCert To vChain If (IsComObject(vChain)) Begin Get Create (RefClass(cComChilkatCertChain)) To hoChain Set pvComObject Of hoChain To vChain End // Note: This example requires Chilkat v9.5.0.87 or greater to resolve a problem found when using // the above data. Get ComNumCerts Of hoChain To iNumCerts Move 0 To i While (i < iNumCerts) Get ComGetCert Of hoChain i To vCertInChain If (IsComObject(vCertInChain)) Begin Get Create (RefClass(cComChilkatCert)) To hoCertInChain Set pvComObject Of hoCertInChain To vCertInChain End Get ComSubjectCN Of hoCertInChain To sTemp1 Showln (i + 1) ": " sTemp1 Send Destroy of hoCertInChain Move (i + 1) To i Loop Send Destroy of hoChain End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.