Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
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. Dim mailman As New ChilkatMailMan2 ' Any string argument automatically begins the 30-day trial. Dim success As Long success = mailman.UnlockComponent("30-day trial") If (success <> 1) Then MsgBox "Component unlock failed" Exit Sub End If ' Set the GMail account POP3 properties. mailman.MailHost = "pop.gmail.com" mailman.PopUsername = "chilkat.support" mailman.PopPassword = "****" mailman.PopSsl = 1 mailman.MailPort = 995 ' Use our certificate, which is already installed ' in our current-user certificate store on the computer. Dim clientCert As New ChilkatCert success = clientCert.LoadByCommonName("Chilkat Software, Inc.") If (success <> 1) Then MsgBox clientCert.LastErrorText Exit Sub End If ' 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 <> 1) Then MsgBox mailman.LastErrorText Exit Sub End If ' Let's look at the LastErrorText to see the details ' of the successful connection. We should see our cert: Text1.Text = Text1.Text & mailman.LastErrorText & vbCrLf ' OK, now examine the server's cert: Dim serverCert As ChilkatCert Set serverCert = mailman.GetPop3SslServerCert() If (serverCert Is Nothing ) Then MsgBox "No server cert available." Else Text1.Text = Text1.Text & "Server SSL certificate:" & vbCrLf Text1.Text = Text1.Text & serverCert.SubjectDN & vbCrLf ' Was the server certificate verified? ' It's not necessarily an error if the SSL Server cert is not verified. If (mailman.Pop3SslServerCertVerified = 1) Then Text1.Text = Text1.Text & "Server SSL certificate was verified." & vbCrLf Else Text1.Text = Text1.Text & "Server SSL certificate was NOT verified!" & vbCrLf End If End If |
© 2000-2012 Chilkat Software, Inc. All Rights Reserved.