MFC Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

MFC Examples

Bounced Mail
Bz2
Certificates/Keys
Charset
CSV
Diffie-Hellman
DSA
Email Object
Encryption
FileAccess
FTP
HTML-to-XML
HTTP
IMAP
MHT / HTML Email
MIME
POP3
RSA
SMTP
Socket
Spider
SSH Key
SSH
SSH Tunnel
SFTP
Tar
Upload
XML
Zip


 

 

 

 

 

 

 

 

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 C/C++ Libraries for VC++ 9.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 8.0 / Win32

Download Chilkat C/C++ 64-bit Libraries for VC++ 8.0 / x64

Download Chilkat Visual Studio 2005 C/C++ Libs for Windows Mobile, Pocket PC, SmartPhone, WinCE

Download Chilkat C/C++ Libraries for VC++ 7.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 6.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 6.0, Win 95/98/NT4 Compatible

// Needs #include <CkMailMan.h>
// Needs #include <CkCert.h>

    CkString strOut;

    //  The mailman object is used for receiving (POP3)
    //  and sending (SMTP) email.
    CkMailMan mailman;

    //  Any string argument automatically begins the 30-day trial.
    bool success;
    success = mailman.UnlockComponent("30-day trial");
    if (success != true) {
        strOut.append("Component unlock failed\r\n");
        SetDlgItemText(IDC_EDIT1,strOut.getUnicode());
        return;
    }

    //  Set the GMail account POP3 properties.
    mailman.put_MailHost("pop.gmail.com");
    mailman.put_PopUsername("myLogin");
    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.
    CkCert clientCert;
    success = clientCert.LoadByCommonName("Chilkat Software, Inc.");
    if (success != true) {
        strOut.append(clientCert.lastErrorText());
        strOut.append("\r\n");
        SetDlgItemText(IDC_EDIT1,strOut.getUnicode());
        return;
    }

    //  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) {
        strOut.append(mailman.lastErrorText());
        strOut.append("\r\n");
        SetDlgItemText(IDC_EDIT1,strOut.getUnicode());
        return;
    }

    //  Let's look at the LastErrorText to see the details
    //  of the successful connection.  We should see our cert:
    strOut.append(mailman.lastErrorText());
    strOut.append("\r\n");

    //  OK, now examine the server's cert:
    CkCert *serverCert = 0;
    serverCert = mailman.GetPop3SslServerCert();
    if (serverCert == 0 ) {
        strOut.append("No server cert available.\r\n");
    }
    else {
        strOut.append("Server SSL certificate:");
        strOut.append("\r\n");
        strOut.append(serverCert->subjectDN());
        strOut.append("\r\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) {
            strOut.append("Server SSL certificate was verified.");
            strOut.append("\r\n");
        }
        else {
            strOut.append("Server SSL certificate was NOT verified!");
            strOut.append("\r\n");
        }

    }


    SetDlgItemText(IDC_EDIT1,strOut.getUnicode());

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

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