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
(Unicode C) Get Certificate Chain CertsDemonstrates how to get the certs in the chain of authentication for a certificate loaded from the Windows certificate store.
#include <C_CkCertW.h> #include <C_CkCertChainW.h> void ChilkatSample(void) { HCkCertW cert; BOOL success; HCkCertChainW chain; int numCerts; int i; HCkCertW certInChain; const wchar_t *b64; cert = CkCertW_Create(); // This example will get the SSL server certificate for tools.chilkat.io // which we happen to have locally installed in our Windows certificate store. success = CkCertW_LoadByCommonName(cert,L"tools.chilkat.io"); if (success == FALSE) { wprintf(L"%s\n",CkCertW_lastErrorText(cert)); CkCertW_Dispose(cert); return; } chain = CkCertW_GetCertChain(cert); if (CkCertW_getLastMethodSuccess(cert) == FALSE) { wprintf(L"%s\n",CkCertW_lastErrorText(cert)); CkCertW_Dispose(cert); return; } numCerts = CkCertChainW_getNumCerts(chain); i = 0; while (i < numCerts) { certInChain = CkCertChainW_GetCert(chain,i); wprintf(L"%d: %s\n",i + 1,CkCertW_subjectCN(certInChain)); // Get this certificate in base64 format b64 = CkCertW_getEncoded(certInChain); wprintf(L"%s\n",b64); CkCertW_Dispose(certInChain); i = i + 1; } CkCertChainW_Dispose(chain); // The output of the above code is: // 1: tools.chilkat.io // MIIGdzCCBV+gAwIBAgIQah36/0eUf3vjWnJEqykBITANBgkqhkiG9w0BAQsFADCB // jzELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G // A1UEBxMHU2FsZm9yZDEYMBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkMTcwNQYDVQQD // Ey5TZWN0aWdvIFJTQSBEb21haW4gV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20wMQYDVR0RBCowKIIQ // dG9vbHMuY2hpbGthdC5pb4IUd3d3LnRvb2xzLmNoaWxrYXQuaW8wggF9BgorBgEE // AdZ5AgQCBIIBbQSCAWkBZwB1APZclC/RdzAiFFQYCDCUVo7jTRMZM7/fDC8gC8xO // 8WTjAAABbSe5NSgAAAQDAEYwRAIge5XZG/r8MyMtCaq3dFIupz0HOuixpiDn7QY7 // mZbyCZoCIA8vxER7vGJw4u0Jd3I1hbjmJ5jgd8tuS6IJqUMSLynDAHYARJRlLrDu // zq/EQAfYqP4owNrmgr7YyzG1P9MzlrW2gagAAAFtJ7k1OQAABAMARzBFAiEAt/1A // XP+UsqZLGrYs/tTYEXhbKsbGdqjkiFJ/pMaAzfgCIBFBekEL3VZlcNqiH+VeeUco // J64Q7Beli3EXYkpNBcUWAHYAVYHUwhaQNgFK6gubVzxT8MDkOHhwJQgXL6OqHQcT // 0wwAAAFtJ7k1VwAABAMARzBFAiEAx5eeXuST2cUbvPiIMjng9nVOhVThuS8S+LtB // Qmd0kY0CIEM1RNaXfxaVfw55yAgOdDMUkHK30Fr9sEpoHC8JjP/nMA0GCSqGSIb3 // DQEBCwUAA4IBAQCPIum32PWfyKW5q08telvzsPRJszPmPEp7OQM7uZebcSwDs9JC // 4zm9UAQyOdkUc7YhqFFNnRZqIW4saEJKEo4QkGeDNXHuCYJfFMr4RdZcQWCeGPdQ // cWPp+Ef0nOEw/sUhq9+bBnWsW2xZ78ZmIQd5D/mWoftVDRANCxE3o75Q+bwwsHDx // TEE/KH4dnlAgL8YH1baUcLtp7CrfPe2E20r8SqDa+AOLx6UdOup5Biez7KvFVdP9 // QkLUfADZxMzFV1Bnq+8bDCDt6mm184OAQvTS30Uxvy5gZ3FQNHUeqRG2LkL/2qGY // rlswE8OkrED07VhRMt0skT2QZsD2U6aiCkAw // // 2: Sectigo RSA Domain Validation Secure Server CA // MIIGEzCCA/ugAwIBAgIQfVtRJrR2uhHbdBYLvFMNpzANBgkqhkiG9w0BAQwFADC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oPv10Yy+xUGUJ // 5lhCLkMaTLTwJUdZ+gQek9QmRkpQgbLevni3/GcV4clXhB4PY9bpYrrWX1Uu6lzG // KAgEJTm4Diup8kyXHAc/DVL17e8vgg8CAwEAAaOB8jCB7zAfBgNVHSMEGDAWgBSg // EQojPpbxB+zirynvgqV/0DCktDAdBgNVHQ4EFgQUU3m/WqorSs9UgOHYm8Cd8rID // ZsswDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMBAf8wEQYDVR0gBAowCDAG // BgRVHSAAMEMGA1UdHwQ8MDowOKA2oDSGMmh0dHA6Ly9jcmwuY29tb2RvY2EuY29t // L0FBQUNlcnRpZmljYXRlU2VydmljZXMuY3JsMDQGCCsGAQUFBwEBBCgwJjAkBggr // BgEFBQcwAYYYaHR0cDovL29jc3AuY29tb2RvY2EuY29tMA0GCSqGSIb3DQEBDAUA // A4IBAQAYh1HcdCE9nIrgJ7cz0C7M7PDmy14R3iJvm3WOnnL+5Nb+qh+cli3vA0p+ // rvSNb3I8QzvAP+u431yqqcau8vzY7qN7Q/aGNnwU4M309z/+3ri0ivCRlv79Q2R+ // /czSAaF9ffgZGclCKxO/WIu6pKJmBHaIkU4MiRTOok3JMrO66BQavHHxW/BBC5gA // CiIDEOUMsfnNkjcZ7Tvx5Dq2+UUTJnWvu6rvP3t3O9LEApE9GQDTF1w52z97GA1F // zZOFli9d31kWTz9RvdVFGD/tSo7oBmF0Ixa1DVBzJ0RHfxBdiSprhTEUxOipakyA // vGp4z7h/jnZymQyd/teRCBaho1+V // // 4: AAA Certificate Services // MIIEMjCCAxqgAwIBAgIBATANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJHQjEb // MBkGA1UECAwSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRow // GAYDVQQKDBFDb21vZG8gQ0EgTGltaXRlZDEhMB8GA1UEAwwYQUFBIENlcnRpZmlj // YXRlIFNlcnZpY2VzMB4XDTA0MDEwMT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bDdVCYfeU0BsWO/8tqtlbgT2 // G9w84FoVxp7Z8VlIMCFlA2zs6SFz7JsDoeA3raAVGI/6ugLOpyypEBMs1OUIJqsi // l2D4kF501KKaU73yqWjgom7C12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3 // smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg== CkCertW_Dispose(cert); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.