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

Extract Public/Private Keys and Certs from PFX into String Variables

Demonstrates how to export certificates and public/private keys from a PFX file into in-memory strings.

LOCAL lnSuccess
LOCAL loCertStore
LOCAL lcPassword
LOCAL i
LOCAL lnNumCerts
LOCAL loCert
LOCAL lcFname
LOCAL lcEncodedCert
LOCAL loCert2
LOCAL loPvkey
LOCAL lcPemPvKey
LOCAL lcPkcs8PvKey
LOCAL lcXmlPvKey
LOCAL loPvKey2
LOCAL loPubkey
LOCAL lcPubKeyPem
LOCAL lcPubKeyXml
LOCAL loPubKey2


loCertStore = CreateObject('Chilkat.CertStore')

*  Load the PFX file into a certificate store object

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

lnNumCerts = loCertStore.NumCertificates

*  Loop over each certificate in the PFX.

FOR i = 0 TO lnNumCerts - 1

    loCert = loCertStore.GetCertificate(i)

    ? loCert.SubjectDN
    ? "---"

    lcEncodedCert = loCert.GetEncoded()

    *  This string may now be stored in a relational database string field.
    *  To re-create the cert, do this:
    loCert2 = CreateObject('Chilkat.Cert')
    loCert2.SetFromEncoded(lcEncodedCert)

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

        *  Get the private key.

        loPvkey = loCert.ExportPrivateKey()

        *  The private key can be exported into
        *  a string in PKCS8, RSA PEM, or XML format:

        lcPemPvKey = loPvkey.GetRsaPem()
        lcPkcs8PvKey = loPvkey.GetPkcs8Pem()
        lcXmlPvKey = loPvkey.GetXml()

        ? lcPemPvKey
        ? lcPkcs8PvKey
        ? lcXmlPvKey

        *  Any of these formatted strings may
        *  be stored in a relational database field.
        *  to restore, call LoadPem or LoadXml
        *  LoadPem accepts either RSA PEM or
        *  PKCS8 PEM:
        loPvKey2 = CreateObject('Chilkat.PrivateKey')

        loPvKey2.LoadPem(lcPemPvKey)
        loPvKey2.LoadPem(lcPkcs8PvKey)
        loPvKey2.LoadXml(lcXmlPvKey)

        RELEASE loPvkey

    ENDIF

    *  Now for the public key:

    loPubkey = loCert.ExportPublicKey()

    *  It can be exported to a string as OpenSSL PEM
    *  or XML:

    lcPubKeyPem = loPubkey.GetOpenSslPem()
    lcPubKeyXml = loPubkey.GetXml()

    ? lcPubKeyPem
    ? lcPubKeyXml

    *  To re-load a PublicKey object, call LoadXml
    *  or LoadOpenSslPem:
    loPubKey2 = CreateObject('Chilkat.PublicKey')

    loPubKey2.LoadOpenSslPem(lcPubKeyPem)
    loPubKey2.LoadXml(lcPubKeyXml)
    lcFname = "pubkey" + STR(i) + "_openSsl.der"
    loPubkey.SaveOpenSslDerFile(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