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

HTTPS Upload with Client SSL Certificate

Download Chilkat HTTP ActiveX

This example shows how to use a client-side certificate with HTTPS to upload one or more files to a web server.

LOCAL lnSuccess
LOCAL loCertStore
LOCAL loCert
LOCAL loCert2
LOCAL loHttp
LOCAL loReq
LOCAL lcDomain
LOCAL lnPort
LOCAL lnSsl
LOCAL loResp



*  Chilkat supports SSL with all of its Internet components:
*  SMTP, POP3, IMAP, FTP, and HTTP.

*  Each component includes a method named SetSslClientCert
*  which has one argument -- a Chilkat certificate object.
*  You'll need to use a certificate where you have
*  a private key.  There are many ways to instantiate
*  and load a certificate into a Chilkat certificate object.
*  It may be loaded directly from a .pfx (or .p12) file.
*  It may be loaded from a certificate that has already
*  been installed into the local machine's (registry-based)
*  certificate store, or the current-user certificate store.
*  It may be loaded from a pair of PEM or DER encoded files
*  (one file for the ceritifcate, and one for the corresponding
*  private key).  Browse through the examples at
*  example-code.com for various examples (in the Digital
*  Certificates section).

*  This example will load a cert from a .pfx (i.e. p12) file.

*  Create an instance of a certificate store object, load a PFX file,
*  locate the certificate we need, and use it for signing.
*  (a PFX file may contain more than one certificate.)
loCertStore = CreateObject('Chilkat.CertStore')
*  The 1st argument is the filename, the 2nd arg is the
*  PFX file's password:
lnSuccess = loCertStore.LoadPfxFile("chilkat.pfx","secret")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loCertStore.LastErrorText)
    QUIT
ENDIF

loCert = loCertStore.FindCertBySubjectCN("Chilkat Software, Inc.")
IF (loCert = NULL ) THEN
    =MESSAGEBOX(loCertStore.LastErrorText)
    QUIT
ENDIF

*  If a PFX file is known to contain a single certificate,
*  you may load it directly into a Chilkat certificate object.
*  This snippet of source code shows how:
loCert2 = CreateObject('Chilkat.Cert')
*  The 1st argument is the filename, the 2nd arg is the
*  PFX file's password:
lnSuccess = loCert2.LoadPfxFile("chilkat.pfx","secret")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loCert2.LastErrorText)
    QUIT
ENDIF

loHttp = CreateObject('Chilkat.Http')

*  Any string unlocks the component for the 1st 30-days.
lnSuccess = loHttp.UnlockComponent("Anything for 30-day trial")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loHttp.LastErrorText)
    QUIT
ENDIF

*  Set your HTTPS client certificate:
loHttp.SetSslClientCert(loCert)

*  Build a HTTPS upload request with the files to be uploaded:
loReq = CreateObject('Chilkat.HttpRequest')
loReq.UseUpload()

*  The URL we'll be posting to is:
*  http://www.yourwebserver123abc.com/ConsumeUpload.aspx
*  Therefore, the path part of the URL is:
loReq.Path = "/ConsumeUpload.aspx"

*  Note: You'll need to edit this example to upload to your
*  own web server.

*  Add some files to the request:
*  The 1st argument is an arbitrary name.  It's the POST form field name.
*  The 2nd argument is the filename currently existing on
*  the local filesystem.  It may include an absolute or relative
*  path, or no path at all if it's in the current working directory.
lnSuccess = loReq.AddFileForUpload("file1","hamlet.xml")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loReq.LastErrorText)
    QUIT
ENDIF

lnSuccess = loReq.AddFileForUpload("file2","dude.gif")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loReq.LastErrorText)
    QUIT
ENDIF

*  Send the HTTPS POST and get the response.  Note: This is a blocking call.
*  The method does not return until the full HTTPS response is received.

lcDomain = "www.yourwebserver123abc.com"
*  The only difference in coding between non-SSL and SSL is
*  the setting of these two arguments to SynchronousRequest:
lnPort = 443
lnSsl = 1

loResp = loHttp.SynchronousRequest(lcDomain,lnPort,lnSsl,loReq)
IF (loResp = NULL ) THEN
    ? loHttp.LastErrorText
ELSE
    *  Display the HTML source of the page returned.
    ? loResp.BodyStr
ENDIF

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

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