![]() |
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
PFX to PEM (Certificate and Private Key Files)Export a certificate and private key from a PFX to a pair of PEM files. <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <% set certStore = Server.CreateObject("Chilkat_9_5_0.CertStore") ' Load the PFX file into a certificate store object password = "myPassword" success = certStore.LoadPfxFile("chilkat.pfx",password) If (success <> 1) Then Response.Write certStore.LastErrorText & "<br>" End If ' Find the cert to be exported by the subject: ' cert is a Chilkat_9_5_0.Cert Set cert = certStore.FindCertBySubject("Chilkat Software, Inc.") If (cert Is Nothing ) Then Response.Write "Certificate not found." & "<br>" End If ' Does this cert have a private key? If (cert.HasPrivateKey() = 1) Then ' Get the private key. ' pvkey is a Chilkat_9_5_0.PrivateKey Set pvkey = cert.ExportPrivateKey() ' Export the private key to a PEM file: success = pvkey.SaveRsaPemFile("chilkat_pkey.pem") If (success <> 1) Then Response.Write pvkey.LastErrorText & "<br>" End If End If ' Save the cert to a PEM file: success = cert.ExportCertPemFile("chilkat_cert.pem") If (success <> 1) Then Response.Write cert.LastErrorText & "<br>" End If %> </body> </html> |
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.