FoxPro Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Visual FoxPro Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML-to-XML
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...
Email Object
RSS
Atom
Byte Array
Service
PPMD
Deflate
DH Key Exchange
DSA

Unreleased...
FileAccess
Bzip2
LZW
Icon

 

Non-Chilkat Links
Text and String Handling

Export Certificate and Private Key to PFX

Demonstrates how to export a digital certificate, it's private key, and potentially all certificates in the chain of authentication to a PFX file.

LOCAL lnSuccess
LOCAL loCcs
LOCAL loCertStore
LOCAL loCert
LOCAL lnBIncludeChain



*  This object is used to create a certificate store object.
loCcs = CreateObject('Chilkat.CreateCS')

*  Open the local machine certificate store read-only.
loCcs.ReadOnly = 1
loCertStore = loCcs.OpenLocalSystemStore()

*  Can we find a certificate by email address?

loCert = loCertStore.FindCertBySubjectE("admin@chilkatsoft.com")
IF (loCert = NULL ) THEN
    *  Open the current-user certificate store and check it instead.
    RELEASE loCertStore
    ? "Checking current-user certificate store..."

    loCertStore = loCcs.OpenCurrentUserStore()

    loCert = loCertStore.FindCertBySubjectE("admin@chilkatsoft.com")
    IF (loCert = NULL ) THEN
        ? "Failed to find certificate!"
        QUIT
    ENDIF

ENDIF

RELEASE loCertStore

*  Does this certificate have a private key accessible
*  to the calling process?  Private keys are *not* stored
*  within the certificate store.  Private keys are stored
*  in a key container in a Windows protected store.  It
*  can be one of two protected stores: the protected store for
*  the current logged-in user account, or the "machine-key"
*  protected store.  The private key must both exist in a
*  protected store, and the process must have permission to
*  access it...

*  You can only export to a PFX if the private key exists
*  and is accessible.

IF (loCert.HasPrivateKey() = 1) THEN

    *  Export to a PFX.
    *  Provide a password that will be required whenever the PFX is opened.
    *  Also, include all certs in the chain of authentication.

    lnBIncludeChain = 1
    lnSuccess = loCert.ExportToPfxFile("myCert.pfx","myPassword",lnBIncludeChain)
    IF (lnSuccess <> 1) THEN
        ? loCert.LastErrorText
    ELSE
        ? "Exported to PFX!"
    ENDIF

ELSE
    ? "Certificate does not have a private key available"
ENDIF

RELEASE loCert

*  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.

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