![]() |
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
(Lianja) 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.
llSuccess = .F. // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loPem = createobject("CkPem") // Load the PEM from a file. // If the PEM is encrypted, provide a password. Otherwise pass an empty string for the password. lcPassword = "myPassword" llSuccess = loPem.LoadPemFile("../myPemFiles/myPem.pem",lcPassword) if (llSuccess = .F.) then ? loPem.LastErrorText release loPem return 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 ..." llSuccess = loPem.LoadPem(lcPemContent,lcPassword) // Check for success as before.. // Iterate over the private keys. lnNumPrivateKeys = loPem.NumPrivateKeys i = 0 loPrivKey = createobject("CkPrivateKey") 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("CkCert") 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.