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
(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.)
LOCAL loSbCertBase64 LOCAL lnSuccess LOCAL loCert LOCAL loPubKey LOCAL lnNumBits LOCAL loXml LOCAL loBinDat * For this example, I have a certificate in raw base64 format (not PEM), * that looks like this: "MIIGkDCCBHigAwIBAgIUMDA ... s/iqLsLA==" * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder') loSbCertBase64 = CreateObject('Chilkat.StringBuilder') lnSuccess = loSbCertBase64.LoadFile("qa_data/certs/base64Cert.txt","utf-8") * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Cert') loCert = CreateObject('Chilkat.Cert') lnSuccess = loCert.LoadFromBase64(loSbCertBase64.GetAsString()) IF (lnSuccess <> 1) THEN ? loCert.LastErrorText RELEASE loSbCertBase64 RELEASE loCert CANCEL ENDIF * Get the public key. loPubKey = loCert.ExportPublicKey() IF (loCert.LastMethodSuccess <> 1) THEN ? loCert.LastErrorText RELEASE loSbCertBase64 RELEASE loCert CANCEL ENDIF * In Chilkat version v9.5.0.67, the KeySize property was added. lnNumBits = loPubKey.KeySize ? "Number of bits = " + STR(lnNumBits) * If using an older version of Chilkat, the key size can be obtained like this: * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Xml') loXml = CreateObject('Chilkat.Xml') loXml.LoadXml(loPubKey.GetXml()) * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.BinData') loBinDat = CreateObject('Chilkat.BinData') loBinDat.AppendEncoded(loXml.GetChildContent("Modulus"),"base64") lnNumBits = 8 * loBinDat.NumBytes ? "Number of bits = " + STR(lnNumBits) RELEASE loPubKey RELEASE loSbCertBase64 RELEASE loCert RELEASE loXml RELEASE loBinDat |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.