Ruby Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Ruby
Examples

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

More Examples...
String
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor

Unreleased...
Service
PPMD
Deflate
Bzip2
LZW
Bz2
DH Key Exchange
DSA
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 Ruby Library

require 'chilkat'

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

#  Any string argument automatically begins the 30-day trial.
success = mailman.UnlockComponent("30-day trial")
if (success != true)
    print "Component unlock failed" + "\n"
    exit
end

#  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.new()
success = clientCert.LoadByCommonName("Chilkat Software, Inc.")
if (success != true)
    print clientCert.lastErrorText() + "\n"
    exit
end

#  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() + "\n"
    exit
end

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

#  OK, now examine the server's cert:

serverCert = mailman.GetPop3SslServerCert()
if (serverCert == nil )
    print "No server cert available." + "\n"
else
    print "Server SSL certificate:" + "\n";
    print serverCert.subjectDN() + "\n";

    #  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." + "\n";
    else
        print "Server SSL certificate was NOT verified!" + "\n";
    end

end


 

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

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