![]() |
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) Iterate Keys and Certs in PEMDemonstrates how to access each of the private keys and certs contained within a PEM. Note: This example requires Chilkat v11.0.0 or greater.
LOCAL lnSuccess LOCAL loPem LOCAL lcPassword LOCAL lcPemContent LOCAL lnNumPrivateKeys LOCAL i LOCAL loPrivKey LOCAL loCert LOCAL lnNumCerts lnSuccess = 0 * This example assumes the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. loPem = CreateObject('Chilkat.Pem') * Load the PEM from a file. * If the PEM is encrypted, provide a password. Otherwise pass an empty string for the password. lcPassword = "myPassword" lnSuccess = loPem.LoadPemFile("../myPemFiles/myPem.pem",lcPassword) IF (lnSuccess = 0) THEN ? loPem.LastErrorText RELEASE loPem CANCEL ENDIF * Note: If the app already has the PEM pre-loaded in a string variable, then load it * by calling LoadPem instead. lcPemContent = "... the PEM contents ..." lnSuccess = loPem.LoadPem(lcPemContent,lcPassword) * Check for success as before.. * Iterate over the private keys. lnNumPrivateKeys = loPem.NumPrivateKeys i = 0 loPrivKey = CreateObject('Chilkat.PrivateKey') DO WHILE i < lnNumPrivateKeys loPem.PrivateKeyAt(i,loPrivKey) ? "Private Key " + STR(i) + " is " + STR(loPrivKey.BitLength) + " in length" i = i + 1 ENDDO * Iterate over the certificates. loCert = CreateObject('Chilkat.Cert') lnNumCerts = loPem.NumCerts i = 0 DO WHILE i < lnNumCerts loPem.CertAt(i,loCert) ? "Certificate " + STR(i) + " : " + loCert.SubjectDN i = i + 1 ENDDO RELEASE loPem RELEASE loPrivKey RELEASE loCert |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.