![]() |
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
(Visual FoxPro) Get a Certificate's Key SizeDemonstrates how to get the RSA key size of a certificate (for example, 1024-bit, 2048-bit, etc.) Note: This example requires Chilkat v11.0.0 or greater.
LOCAL lnSuccess LOCAL loSbCertBase64 LOCAL loCert LOCAL loPubKey LOCAL lnNumBits LOCAL loXml LOCAL loBinDat lnSuccess = 0 * For this example, I have a certificate in raw base64 format (not PEM), * that looks like this: "MIIGkDCCBHigAwIBAgIUMDA ... s/iqLsLA==" loSbCertBase64 = CreateObject('Chilkat.StringBuilder') lnSuccess = loSbCertBase64.LoadFile("qa_data/certs/base64Cert.txt","utf-8") loCert = CreateObject('Chilkat.Cert') lnSuccess = loCert.LoadFromBase64(loSbCertBase64.GetAsString()) IF (lnSuccess = 0) THEN ? loCert.LastErrorText RELEASE loSbCertBase64 RELEASE loCert CANCEL ENDIF * Get the public key. loPubKey = CreateObject('Chilkat.PublicKey') loCert.GetPublicKey(loPubKey) lnNumBits = loPubKey.KeySize ? "Number of bits = " + STR(lnNumBits) * If using an older version of Chilkat, the key size can be obtained like this: loXml = CreateObject('Chilkat.Xml') loXml.LoadXml(loPubKey.GetXml()) loBinDat = CreateObject('Chilkat.BinData') loBinDat.AppendEncoded(loXml.GetChildContent("Modulus"),"base64") lnNumBits = 8 * loBinDat.NumBytes ? "Number of bits = " + STR(lnNumBits) RELEASE loSbCertBase64 RELEASE loCert RELEASE loPubKey RELEASE loXml RELEASE loBinDat |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.