Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Create PFX from PEM (Certificate and Private Key Files)Create a PFX file from a pair of PEM files (the certificate PEM and private key PEM). LOCAL lnSuccess LOCAL loCert LOCAL loPrivkey LOCAL lnBMachineKeyset LOCAL lnBForSigning LOCAL loKeyCont LOCAL lnBIncludeCertsInChain loCert = CreateObject('Chilkat.Cert') lnSuccess = loCert.LoadFromFile("chilkat_cert.pem") IF (lnSuccess <> 1) THEN =MESSAGEBOX(loCert.LastErrorText) QUIT ENDIF loPrivkey = CreateObject('Chilkat.PrivateKey') lnSuccess = loPrivkey.LoadPemFile("chilkat_pkey.pem") IF (lnSuccess <> 1) THEN =MESSAGEBOX(loPrivkey.LastErrorText) QUIT ENDIF * Link the cert to the private key. * Use the current logged-on user's protected key store: lnBMachineKeyset = 0 * If the private key is to be used for creating signatures, * set bForSigning = 1. If the private key is to be * used for decrypting, set bForSigning = 0 lnBForSigning = 1 * Select an arbitrary key container name that is unique * to your application. Make sure it exists: loKeyCont = CreateObject('Chilkat.KeyContainer') * The CreateContainer method will create the key container * if it does not already exist, otherwise it will open it. * (The key container is in the Windows protected store.) lnSuccess = loKeyCont.CreateContainer("myApp",lnBMachineKeyset) IF (lnSuccess <> 1) THEN =MESSAGEBOX(loKeyCont.LastErrorText) QUIT ENDIF lnSuccess = loCert.LinkPrivateKey("myApp",lnBMachineKeyset,lnBForSigning) IF (lnSuccess <> 1) THEN =MESSAGEBOX(loCert.LastErrorText) QUIT ENDIF * Now export to a PFX: lnBIncludeCertsInChain = 0 lnSuccess = loCert.ExportToPfxFile("chilkat2.pfx","myPassword",lnBIncludeCertsInChain) IF (lnSuccess <> 1) THEN =MESSAGEBOX(loCert.LastErrorText) QUIT ENDIF =MESSAGEBOX("PFX created!") |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2007 Chilkat Software, Inc. All Rights Reserved.
Mail Component · .NET Email Component · ASP Mail Component · XML Parser