Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
SSL POP3 with CertificatesDemonstrates 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.
// The mailman object is used for receiving (POP3) // and sending (SMTP) email. Chilkat.MailMan mailman = new Chilkat.MailMan(); // Any string argument automatically begins the 30-day trial. bool success; success = mailman.UnlockComponent("30-day trial"); if (success != true) { MessageBox.Show("Component unlock failed"); return; } // Set the GMail account POP3 properties. mailman.MailHost = "pop.gmail.com"; mailman.PopUsername = "chilkat.support"; mailman.PopPassword = "****"; mailman.PopSsl = true; mailman.MailPort = 995; // Use our certificate, which is already installed // in our current-user certificate store on the computer. Chilkat.Cert clientCert = new Chilkat.Cert(); success = clientCert.LoadByCommonName("Chilkat Software, Inc."); if (success != true) { MessageBox.Show(clientCert.LastErrorText); 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) { MessageBox.Show(mailman.LastErrorText); return; } // Let's look at the LastErrorText to see the details // of the successful connection. We should see our cert: textBox1.Text += mailman.LastErrorText + "\r\n"; // OK, now examine the server's cert: Chilkat.Cert serverCert = null; serverCert = mailman.GetPop3SslServerCert(); if (serverCert == null ) { MessageBox.Show("No server cert available."); } else { textBox1.Text += "Server SSL certificate:" + "\r\n"; textBox1.Text += serverCert.SubjectDN + "\r\n"; // Was the server certificate verified? // It's not necessarily an error if the SSL Server cert is not verified. if (mailman.Pop3SslServerCertVerified == true) { textBox1.Text += "Server SSL certificate was verified." + "\r\n"; } else { textBox1.Text += "Server SSL certificate was NOT verified!" + "\r\n"; } } |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.