FoxPro Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

Visual FoxPro Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
Email Object
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
RSA
S/MIME
Socket
Spider
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
String
Tar
Upload
XML
XMP
Zip Compression
Self-Extractor

More Examples...
Amazon S3
DKIM / DomainKey
NTLM
RSS
Atom
Byte Array
Service
PPMD
Deflate
DH Key Exchange
DSA
FileAccess
Bzip2
LZW

 

Non-Chilkat Links
Text and String Handling

Export certificates and public/private keys from a PFX

Demonstrates how to export certificates and public/private keys from a PFX file.

LOCAL lnSuccess
LOCAL loCertStore
LOCAL lcPassword
LOCAL i
LOCAL lnNumCerts
LOCAL loCert
LOCAL lcFname
LOCAL loPvkey
LOCAL loPubkey


loCertStore = CreateObject('Chilkat.CertStore')

*  Load the PFX file into a certificate store object

lcPassword = "myPassword"
lnSuccess = loCertStore.LoadPfxFile("chilkat.pfx",lcPassword)
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loCertStore.LastErrorText)
    QUIT
ENDIF

lnNumCerts = loCertStore.NumCertificates

FOR i = 0 TO lnNumCerts - 1

    loCert = loCertStore.GetCertificate(i)

    ? loCert.SubjectDN
    ? "---"

    *  Save the cert in DER format:
    lcFname = "cert" + STR(i) + ".der"
    loCert.ExportCertDerFile(lcFname)

    *  Save the cert in PEM format:
    lcFname = "cert" + STR(i) + ".pem"
    loCert.ExportCertPemFile(lcFname)

    *  Does this cert have a private key?
    IF (loCert.HasPrivateKey() = 1) THEN

        *  Get the private key.

        loPvkey = loCert.ExportPrivateKey()

        *  Save the private key to a PKCS8 DER-encoded file
        lcFname = "pvkey" + STR(i) + "_pkcs8.der"
        loPvkey.SavePkcs8File(lcFname)

        *  Save the private key to a PKCS8 PEM-encoded file
        lcFname = "pvkey" + STR(i) + "_pkcs8.pem"
        loPvkey.SavePkcs8PemFile(lcFname)

        *  Save the private key to a RSA DER-encoded file
        lcFname = "pvkey" + STR(i) + "_rsa.der"
        loPvkey.SaveRsaDerFile(lcFname)

        *  Save the private key to a RSA PEM-encoded file
        lcFname = "pvkey" + STR(i) + "_rsa.pem"
        loPvkey.SaveRsaPemFile(lcFname)

        *  Save the private key to an XML file
        *  This format is Chilkat-specific, but easily parsed,
        *  making it easy to get the modulus, exponent,
        *  P, Q, DP, DQ, InverseQ, and D.
        lcFname = "pvkey" + STR(i) + ".xml"
        loPvkey.SaveXmlFile(lcFname)

        RELEASE loPvkey

    ENDIF

    *  Now get the public key and save it to various file formats:

    loPubkey = loCert.ExportPublicKey()

    *  Save to an OpenSSL DER format file:
    lcFname = "pubkey" + STR(i) + "_openSsl.der"
    loPubkey.SaveOpenSslDerFile(lcFname)

    *  Save to an OpenSSL PEM format file:
    lcFname = "pubkey" + STR(i) + "_openSsl.pem"
    loPubkey.SaveOpenSslPemFile(lcFname)

    *  Save to an RSA DER format file:
    lcFname = "pubkey" + STR(i) + "_rsa.der"
    loPubkey.SaveRsaDerFile(lcFname)

    *  Save to an XML file:
    *  This format is Chilkat-specific, but easily parsed,
    *  making it easy to get the modulus and exponent.
    lcFname = "pubkey" + STR(i) + ".xml"
    loPubkey.SaveXmlFile(lcFname)

    RELEASE loPubkey

    RELEASE loCert
NEXT

*  The Chilkat Certificate, Certificate Store, Private Key,
*  Public Key, and Key Container classes / objects are freeware.

*  They are used by and included with the Chilkat Email,
*  Crypt, S/MIME, and other commercial Chilkat components.

© 2000-2010 Chilkat Software, Inc. All Rights Reserved.

Mail Component · .NET Email Component · ASP Mail Component · XML Parser