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
(DataFlex) Load PKCS12 / PFX and Access ContentsLoads a PKCS12 / PFX file and iterates over the contents which include private keys and certificates.
Use ChilkatAx-win32.pkg Procedure Test Handle hoPfx Boolean iSuccess Integer iNumPrivateKeys Variant vPrivKey Handle hoPrivKey Integer i Variant vCert Handle hoCert Integer iNumCerts String sTemp1 Boolean bTemp1 Get Create (RefClass(cComChilkatPfx)) To hoPfx If (Not(IsComObjectCreated(hoPfx))) Begin Send CreateComObject of hoPfx End // Load the PKCS12 from a file Get ComLoadPfxFile Of hoPfx "/someDir/my.p12" "pfxFilePassword" To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoPfx To sTemp1 Showln sTemp1 Procedure_Return End Get ComNumPrivateKeys Of hoPfx To iNumPrivateKeys Showln "Private Keys:" Move 0 To i While (i < iNumPrivateKeys) Get ComGetPrivateKey Of hoPfx i To vPrivKey If (IsComObject(vPrivKey)) Begin Get Create (RefClass(cComChilkatPrivateKey)) To hoPrivKey Set pvComObject Of hoPrivKey To vPrivKey End // Do something with the private key ... Send Destroy of hoPrivKey Move (i + 1) To i Loop Get ComNumCerts Of hoPfx To iNumCerts Showln "Certs:" Move 0 To i While (i < iNumCerts) Get ComGetCert Of hoPfx i To vCert If (IsComObject(vCert)) Begin Get Create (RefClass(cComChilkatCert)) To hoCert Set pvComObject Of hoCert To vCert End Get ComSubjectDN Of hoCert To sTemp1 Showln sTemp1 // 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: Get ComHasPrivateKey Of hoCert To bTemp1 If (bTemp1 = True) Begin Showln "Has private key!" Get ComExportPrivateKey Of hoCert To vPrivKey If (IsComObject(vPrivKey)) Begin Get Create (RefClass(cComChilkatPrivateKey)) To hoPrivKey Set pvComObject Of hoPrivKey To vPrivKey End // ... Send Destroy of hoPrivKey End Send Destroy of hoCert Move (i + 1) To i Loop End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.