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
(PowerBuilder) Load PKCS12 / PFX and Access ContentsLoads a PKCS12 / PFX file and iterates over the contents which include private keys and certificates.
integer li_rc oleobject loo_Pfx integer li_Success integer li_NumPrivateKeys oleobject loo_PrivKey integer i oleobject loo_Cert integer li_NumCerts loo_Pfx = create oleobject // Use "Chilkat_9_5_0.Pfx" for versions of Chilkat < 10.0.0 li_rc = loo_Pfx.ConnectToNewObject("Chilkat.Pfx") if li_rc < 0 then destroy loo_Pfx MessageBox("Error","Connecting to COM object failed") return end if // Load the PKCS12 from a file li_Success = loo_Pfx.LoadPfxFile("/someDir/my.p12","pfxFilePassword") if li_Success <> 1 then Write-Debug loo_Pfx.LastErrorText destroy loo_Pfx return end if li_NumPrivateKeys = loo_Pfx.NumPrivateKeys Write-Debug "Private Keys:" i = 0 do while i < li_NumPrivateKeys loo_PrivKey = loo_Pfx.GetPrivateKey(i) // Do something with the private key ... destroy loo_PrivKey i = i + 1 loop li_NumCerts = loo_Pfx.NumCerts Write-Debug "Certs:" i = 0 do while i < li_NumCerts loo_Cert = loo_Pfx.GetCert(i) Write-Debug loo_Cert.SubjectDN // If the certificate has a private key (one of the private keys within the PFX) // then it can also be obtained via the certificate object: if loo_Cert.HasPrivateKey() = 1 then Write-Debug "Has private key!" loo_PrivKey = loo_Cert.ExportPrivateKey() // ... destroy loo_PrivKey end if destroy loo_Cert i = i + 1 loop destroy loo_Pfx |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.