Overview
Features
Download
Documentation
Community
Add-Ons & Services

POP3 with SSL

A general discussion forum.

POP3 with SSL

Postby coldiceangel » 22 Nov 2010, 11:03

If i want to receive email from gmail server, what should I do? Should I derive from POP3ClientSession
as SecureSMTPClientSession(1.3.7 branch) does? Is that job complicated?

Thanks.
coldiceangel
 
Posts: 14
Joined: 03 Nov 2010, 13:37

Re: POP3 with SSL

Postby coldiceangel » 23 Nov 2010, 08:19

When I try to use SecureSMTPClientSession, the app throws an exception, in
Code: Select all
int SecureSocketImpl::handleError(int rc)

line:
Code: Select all
ERR_error_string_n(lastError, buffer, sizeof(buffer));

I saw buffer's content was "error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed", I find nothing useful from google.
How does this happen? I used a self-signed certificate.

Thanks.
coldiceangel
 
Posts: 14
Joined: 03 Nov 2010, 13:37

Re: POP3 with SSL

Postby guenter » 23 Nov 2010, 09:03

For using POP3ClientSession with SSL, you need to first create a Poco::Net::SecureStreamSocket and connect the socket to your POP3 Server. Then you simply create a POP3ClientSession with the Poco::Net::SecureStreamSocket.

Code: Select all
Poco::Net::SocketAddress sa("mailhost", 995);
Poco::Net::SecureStreamSocket sss(sa);
Poco::Net::POP3ClientSession pops(sss);
pops.login("user", "pass");
...


Regarding the error you get from SecureSMTPClientSession: you'll need to set up a certificate handler that accepts the self-signed certificate. By default, self-signed certificates will be rejected.

Do this before creating the SecureSMTPClientSession:


Code: Select all
SharedPtr<InvalidCertificateHandler> ptrCert = new AcceptCertificateHandler(false);
Context::Ptr ptrContext = new Context(Context::CLIENT_USE, "", "", "rootcert.pem", Context::VERIFY_RELAXED, 9, false, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
SSLManager::instance().initializeClient(0, ptrCert, ptrContext);

Alternatively, you can also create the context with Context::VERIFY_NONE.
guenter
 
Posts: 1156
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: POP3 with SSL

Postby coldiceangel » 23 Nov 2010, 09:10

Thank you so much, guenter, you save me! I will try :mrgreen:
coldiceangel
 
Posts: 14
Joined: 03 Nov 2010, 13:37

Re: POP3 with SSL

Postby coldiceangel » 23 Nov 2010, 09:49

POP3/SMTP with ssl all work fine now
coldiceangel
 
Posts: 14
Joined: 03 Nov 2010, 13:37


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron