Python Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Python Examples

Quick Start
Python Unicode
Python Byte Array
Python Certs
Python Email
Python Encryption
Python FTP
HTML-to-XML
Python HTTP
Python IMAP
Python MHT
Python MIME
Python RSA
Python S/MIME
Python Signatures
Python Socket
Python Spider
Python Tar
Python Upload
Python XML
Python XMP
Python Zip

More Examples...
String
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
SSH Key
SSH
SSH Tunnel
SFTP

Unreleased...
Bzip2
LZW
Bz2
Icon

 

 

 

 

 

 

 

SSL POP3 with Certificates

Demonstrates how to use a client-side certificate with an SSL connection to a POP3 server. Also demonstrates how to get the POP3 server's SSL certificate.

Download Chilkat Python Library

import sys
import chilkat

#  The mailman object is used for receiving (POP3)
#  and sending (SMTP) email.
mailman = chilkat.CkMailMan()

#  Any string argument automatically begins the 30-day trial.
success = mailman.UnlockComponent("30-day trial")
if (success != True):
    print "Component unlock failed"
    sys.exit()

#  Set the GMail account POP3 properties.
mailman.put_MailHost("pop.gmail.com")
mailman.put_PopUsername("chilkat.support")
mailman.put_PopPassword("****")
mailman.put_PopSsl(True)
mailman.put_MailPort(995)

#  Use our certificate, which is already installed
#  in our current-user certificate store on the computer.
clientCert = chilkat.CkCert()
success = clientCert.LoadByCommonName("Chilkat Software, Inc.")
if (success != True):
    print clientCert.lastErrorText()
    sys.exit()

#  Note: The GMail POP3 server does not require that you
#  have a client cert.  This example only demonstrates
#  how you may use a client certificate.  Typically,
#  higher-security systems may require a client-side SSL cert.
mailman.SetSslClientCert(clientCert)

#  Establish a POP3 connection:
success = mailman.Pop3BeginSession()
if (success != True):
    print mailman.lastErrorText()
    sys.exit()

#  Let's look at the LastErrorText to see the details
#  of the successful connection.  We should see our cert:
print mailman.lastErrorText()

#  OK, now examine the server's cert:

serverCert = mailman.GetPop3SslServerCert()
if (serverCert == None ):
    print "No server cert available."
else:
    print "Server SSL certificate:"
    print serverCert.subjectDN()

    #  Was the server certificate verified?
    #  It's not necessarily an error if the SSL Server cert is not verified.
    if (mailman.get_Pop3SslServerCertVerified() == True):
        print "Server SSL certificate was verified."
    else:
        print "Server SSL certificate was NOT verified!"


 

Need a specific example? Send a request to support@chilkatsoft.com

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