Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- I do this to load my certificate:
- */
- vmime::ref < vmime::security::cert::X509Certificate > loadX509CertificateFromFile( const std::string &path )
- {
- std::ifstream certFile;
- certFile.open( path.c_str(), std::ios::in | std::ios::binary );
- vmime::utility::inputStreamAdapter is ( certFile );
- vmime::ref < vmime::security::cert::X509Certificate > cert;
- cert = vmime::security::cert::X509Certificate::import( is );
- if ( cert != NULL )
- return cert;
- }
- /*
- And then later on I do this to connect to send my mail:
- */
- ...
- vmime::ref < vmime::security::cert::defaultCertificateVerifier > vrf = vmime::create < vmime::security::cert::defaultCertificateVerifier >();
- std::vector < vmime::ref < vmime::security::cert::X509Certificate > > rootCAs;
- rootCAs.push_back( loadX509CertificateFromFile( "Thawte_Premium_Server_CA.pem" ) );
- vrf->setX509RootCAs( rootCAs );
- m_vmASession = vmime::create< vmime::net::session >();
- vmime::utility::url url("smtps://smtp.gmail.com");
- vmime::ref < vmime::net::transport > tr = m_vmASession->getTransport( url );
- tr->setCertificateVerifier( vrf );
- m_vmASession->getProperties()[ "transport.smtp.auth.username" ] = ui->lineEdit_setUser->text().toAscii().data();
- m_vmASession->getProperties()[ "transport.smtp.auth.password" ] = ui->lineEdit_setPass->text().toAscii().data();
- tr->setProperty( "transport.smtp.options.need-authentication", true );
- tr->setProperty( "options.need-authentication", true );
- tr->setProperty( "auth.username", ui->lineEdit_setUser->text().toAscii().data() );
- tr->setProperty( "auth.pass", ui->lineEdit_setPass->text().toAscii().data() );
- tr->setProperty( "server.port", 465 );
- tr->connect();
- tr->send( vmConstructedMessage );
- tr->disconnect();
- ...
- /*
- But it returns a vmime exception at tr->connect() : "Authentication error." From what I understand, when I connect through port 465 on smtp.gmail.com I use classical ssl/tls ( no starttls, no sasl ) I've tried forcing sasl, adding @gmail.com to the end of my username, and encoding my creds in base64 like I would if I was running AUTH LOGIN through openssl from a terminal. What am I doing wrong?
- I'm using QT C++ on Linux. Thanks a million!
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement