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
(PureBasic) Load PKCS12 / PFX and Access ContentsLoads a PKCS12 / PFX file and iterates over the contents which include private keys and certificates.
IncludeFile "CkCert.pb" IncludeFile "CkPrivateKey.pb" IncludeFile "CkPfx.pb" Procedure ChilkatExample() pfx.i = CkPfx::ckCreate() If pfx.i = 0 Debug "Failed to create object." ProcedureReturn EndIf ; Load the PKCS12 from a file success.i = CkPfx::ckLoadPfxFile(pfx,"/someDir/my.p12","pfxFilePassword") If success <> 1 Debug CkPfx::ckLastErrorText(pfx) CkPfx::ckDispose(pfx) ProcedureReturn EndIf numPrivateKeys.i = CkPfx::ckNumPrivateKeys(pfx) privKey.i Debug "Private Keys:" i.i = 0 While i < numPrivateKeys privKey = CkPfx::ckGetPrivateKey(pfx,i) ; Do something with the private key ... CkPrivateKey::ckDispose(privKey) i = i + 1 Wend cert.i numCerts.i = CkPfx::ckNumCerts(pfx) Debug "Certs:" i = 0 While i < numCerts cert = CkPfx::ckGetCert(pfx,i) Debug CkCert::ckSubjectDN(cert) ; 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 CkCert::ckHasPrivateKey(cert) = 1 Debug "Has private key!" privKey = CkCert::ckExportPrivateKey(cert) ; ... CkPrivateKey::ckDispose(privKey) EndIf CkCert::ckDispose(cert) i = i + 1 Wend CkPfx::ckDispose(pfx) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.