Error “sslv3 alert handshake failure” using Net::SMTP::TLS

吃可爱长大的小学妹 提交于 2019-12-12 14:35:23

问题


I'm trying to send email with Perl. My code works fine with Yahoo's SMTP server but when I try to use another SMTP server (with a self-signed SSL certificate), I get this error:

Couldn't start TLS: SSL connect attempt failed because of handshake problems error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure at mail2.pl line 2.

My code is:

use Net::SMTP::TLS;

my $mailer = new Net::SMTP::TLS(
        'mail.SomeHost.com',
        Hello   =>      'mail.SomeHost.com',
        Port    =>      587,
        User    =>      'info@SomeHost.com',
        Password=>      '123456789'
);

$mailer->mail('info@SomeHost.com');
$mailer->to('info@SomeHost.com');
$mailer->data();
$mailer->datasend("From: info@SomeHost.com\n");
$mailer->datasend("To: info@SomeHost.com\n");
$mailer->datasend("Subject: test\n");
$mailer->datasend("Content-type: text/html\n\n");
$mailer->datasend("\n");
$mailer->datasend("<html><body><p>hi text</p><br></body></html>\n");
$mailer->dataend();
$mailer->quit;

How can I fix this?

Result with -MIO::Socket::SSL=debug4:

DEBUG: .../IO/Socket/SSL.pm:2537: new ctx 17003088
DEBUG: .../IO/Socket/SSL.pm:1343: start handshake
DEBUG: .../IO/Socket/SSL.pm:553: ssl handshake not started
DEBUG: .../IO/Socket/SSL.pm:589: not using SNI because hostname is unknown
DEBUG: .../IO/Socket/SSL.pm:621: request OCSP stapling
DEBUG: .../IO/Socket/SSL.pm:640: set socket to non-blocking to enforce timeout=5
DEBUG: .../IO/Socket/SSL.pm:653: Net::SSLeay::connect -> -1
DEBUG: .../IO/Socket/SSL.pm:663: ssl handshake in progress
DEBUG: .../IO/Socket/SSL.pm:673: waiting for fd to become ready: SSL wants a read first
DEBUG: .../IO/Socket/SSL.pm:693: socket ready, retrying connect
DEBUG: .../IO/Socket/SSL.pm:653: Net::SSLeay::connect -> 0
DEBUG: .../IO/Socket/SSL.pm:701: connection failed - connect returned 0
DEBUG: .../IO/Socket/SSL.pm:1769: SSL connect attempt failed because of handshake problems

DEBUG: .../IO/Socket/SSL.pm:1774: SSL connect attempt failed because of handshake problems
    error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure
DEBUG: .../IO/Socket/SSL.pm:2570: free ctx 17003088 open=17003088
DEBUG: .../IO/Socket/SSL.pm:2575: free ctx 17003088 callback
DEBUG: .../IO/Socket/SSL.pm:2582: OK free ctx 17003088 Couldn't start TLS:
    SSL connect attempt failed because of handshake problems
    error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake
failure  at mail2.pl line 2.

来源:https://stackoverflow.com/questions/34455133/error-sslv3-alert-handshake-failure-using-netsmtptls

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!