raku-community-modules / Net-SMTP

A pure Raku implementation of a SMTP client
MIT License
7 stars 7 forks source link

:ssl crash #17

Open ToddAndMargo opened 7 years ago

ToddAndMargo commented 7 years ago

!/usr/bin/env perl6

use Net::SMTP; my $client = Net::SMTP.new( :server( "smtp.zoho.com" ), :port( 465 ), :ssl, :starttls, :debug( 1 ) );

$ crashme.pl6 err code: 336130329 error:1408F119:SSL routines:SSL3_GET_RECORD:decryption failed or bad record mac Use of uninitialized value of type Str in string context. Methods .^name, .perl, .gist, or .say can be used to stringify it to something meaningful. in method get-response at /home/todd/.perl6/sources/C7BFE131D057F94A1EC6C5CBF4DFC8C731D85400 (Net::SMTP::Raw) line 13 Start argument to substr out of range. Is: 3, should be in 0..0; use *-3 if you want to index relative to the end in method get-response at /home/todd/.perl6/sources/C7BFE131D057F94A1EC6C5CBF4DFC8C731D85400 (Net::SMTP::Raw) line 13 in method start at /home/todd/.perl6/sources/B0AFFC7E1CD3A465D71AF333700CF7086E4870E5 (Net::SMTP::Simple) line 59 in method new at /home/todd/.perl6/sources/AF0C4F60F05B28648456130019BA1D9C3B2FE938 (Net::SMTP) line 38 in block at ./crashme.pl6 line 6

ToddAndMargo commented 7 years ago

https://www.zoho.com/mail/help/zoho-smtp.html

SMTP Configuration settings for Zoho Mail - SSL Outgoing Server Name: smtp.zoho.com Port: 465 Security Type: SSL Require Authentication: Yes.

SMTP Configuration settings for Zoho Mail - TLS Outgoing Server Name: smtp.zoho.com Port: 587 Security Type: TLS

my $client = Net::SMTP.new( :server( "smtp.zoho.com" ), :port( 465 ), :ssl, :debug( 1 ) );

$ crashme.pl6 err code: 336130329 error:1408F119:SSL routines:SSL3_GET_RECORD:decryption failed or bad record mac Use of uninitialized value of type Str in string context. Methods .^name, .perl, .gist, or .say can be used to stringify it to something meaningful. in method get-response at /home/tony/.perl6/sources/C7BFE131D057F94A1EC6C5CBF4DFC8C731D85400 (Net::SMTP::Raw) line 13 Start argument to substr out of range. Is: 3, should be in 0..0; use *-3 if you want to index relative to the end in method get-response at /home/tony/.perl6/sources/C7BFE131D057F94A1EC6C5CBF4DFC8C731D85400 (Net::SMTP::Raw) line 13 in method start at /home/tony/.perl6/sources/B0AFFC7E1CD3A465D71AF333700CF7086E4870E5 (Net::SMTP::Simple) line 59 in method new at /home/tony/.perl6/sources/AF0C4F60F05B28648456130019BA1D9C3B2FE938 (Net::SMTP) line 38 in block at ./crashme.pl6 line 5

my $client = Net::SMTP.new( :server( "smtp.zoho.com" ), :port( 587 ), :starttls, :debug( 1 ) );

$ crashme.pl6 <== 220 mx.zohomail.com SMTP Server ready August 19, 2017 10:18:33 PM PDT ==> EHLO rn4.rent-a-nerd.loca <== 250-mx.zohomail.com Hello rn4.rent-a-nerd.local (50-37-23-91.grdv.nv.frontiernet.net (50.37.23.91)) <== 250-STARTTLS <== 250 SIZE 53477376 ==> STARTTL <== 220 Ready to start TLS. err code: 336130329 error:1408F119:SSL routines:SSL3_GET_RECORD:decryption failed or bad record mac Use of uninitialized value of type Str in string context. Methods .^name, .perl, .gist, or .say can be used to stringify it to something meaningful. in method get-response at /home/tony/.perl6/sources/C7BFE131D057F94A1EC6C5CBF4DFC8C731D85400 (Net::SMTP::Raw) line 13 Start argument to substr out of range. Is: 3, should be in 0..0; use *-3 if you want to index relative to the end in method get-response at /home/tony/.perl6/sources/C7BFE131D057F94A1EC6C5CBF4DFC8C731D85400 (Net::SMTP::Raw) line 13 in method send at /home/tony/.perl6/sources/C7BFE131D057F94A1EC6C5CBF4DFC8C731D85400 (Net::SMTP::Raw) line 22 in method ehlo at /home/tony/.perl6/sources/C7BFE131D057F94A1EC6C5CBF4DFC8C731D85400 (Net::SMTP::Raw) line 25 in method start at /home/tony/.perl6/sources/B0AFFC7E1CD3A465D71AF333700CF7086E4870E5 (Net::SMTP::Simple) line 63 in method new at /home/tony/.perl6/sources/AF0C4F60F05B28648456130019BA1D9C3B2FE938 (Net::SMTP) line 38 in block at ./crashme.pl6 line 6

jhcloos commented 7 years ago

The fact that the errors note SSL3 suggests that the target server only supports the newer tls versions.

Or, if they use the same cert for those two ports as they do for port 25, the issue might be that they provide a cert for *.zoho.com rather than for anything in zohomail.com, thus the client might dislike that the cert is for a different name.

(The above comments are strictly from a tls point of view; I am not at all familiar with the p6 modules.)

ToddAndMargo commented 7 years ago

On 08/20/2017 11:23 AM, James Cloos wrote:

The fact that the errors note SSL3 suggests that the target server only supports the newer tls versions.

Or, if they use the same cert for those two ports as they do for port 25, the issue might be that they provide a cert for *.zoho.com rather than for anything in zohomail.com, thus the client might dislike that the cert is for a different name.

(The above comments are strictly from a tls point of view; I am not at all familiar with the p6 modules.)

Is there a work around? I need to get status and alerts on server raid pairs sent to me.

ToddAndMargo commented 7 years ago

Sorry, I don't mean to rush you guys but I really need to get this going. Do you have a time frame on this? Would it be better for me to revert to Perl 5? (I prefer Perl 6 for its better sub headers and loops. Much easier for me to maintain.)

I am troubleshooting a SATA hot swap issue that knocks the RAID 1 pairs out of sync (you have to flip the power off to recover after the file system hoses itself). So I has become a really big deal to get status reports on the RAID status.

timo commented 7 years ago

i cannot reproduce the problem with this code

use Net::SMTP;
my $client = Net::SMTP.new(
    :server( "smtp.zoho.com" ),
    :port( 587 ),
    :starttls,
    :debug( 1 ),
    :simple );
$client.auth("hello", "goodbye");'

i don't think i'd have to authenticate correctly because in your error output no authentication appears.

here's my output:

<== 220 mx.zohomail.com SMTP Server ready August 27, 2017 12:33:26 AM PDT
==> EHLO schmetterlin
<== 250-mx.zohomail.com Hello schmetterling (64.239.197.178.dynamic.wless.lssmb00p-cgnat.res.cust.swisscom.ch (178.197.239.64))
<== 250-STARTTLS
<== 250 SIZE 53477376
==> STARTTL
<== 220 Ready to start TLS.
Authentication failed:  The server responded with
535 Authentication Failed
  in method auth at /home/timo/perl6/install/share/perl6/site/sources/B0AFFC7E1CD3A465D71AF333700CF7086E4870E5 (Net::SMTP::Simple) line 134
  in block <unit> at -e line 1

though it does seem like once starttls has happened the debug printer no longer prints what's going on? i don't see my outgoing auth attempt.

ToddAndMargo commented 7 years ago

Is there any way to force SSL3 ?

The following is for both port 587 (starttls) and 465 (ssl[3]):

!/usr/bin/env perl6

use Net::SMTP; my $client = Net::SMTP.new( :server( "smtp.zoho.com" ), :port( 587 ), :starttls, :simple, :debug( 1 ) ); $client.auth("hello", "goodbye");

$ crashme.pl6 <== 220 mx.zohomail.com SMTP Server ready August 27, 2017 5:23:19 PM PDT ==> EHLO rn4.xxxxx.loca <== 250-mx.zohomail.com Hello rn4.xxxxxx.local (aa-bb-cc-dd.grdv.nv.frontiernet.net (aa.dd.cc.dd)) == 250-STARTTLS <== 250 SIZE 53477376 ==> STARTTL <== 220 Ready to start TLS. err code: 336130329 error:1408F119:SSL routines:SSL3_GET_RECORD:decryption failed or bad record mac Use of uninitialized value of type Str in string context. Methods .^name, .perl, .gist, or .say can be used to stringify it to something meaningful. in method get-response at /home/todd/.perl6/sources/C7BFE131D057F94A1EC6C5CBF4DFC8C731D85400 (Net::SMTP::Raw) line 13 Start argument to substr out of range. Is: 3, should be in 0..0; use *-3 if you want to index relative to the end in method get-response at /home/todd/.perl6/sources/C7BFE131D057F94A1EC6C5CBF4DFC8C731D85400 (Net::SMTP::Raw) line 13 in method send at /home/todd/.perl6/sources/C7BFE131D057F94A1EC6C5CBF4DFC8C731D85400 (Net::SMTP::Raw) line 22 in method ehlo at /home/todd/.perl6/sources/C7BFE131D057F94A1EC6C5CBF4DFC8C731D85400 (Net::SMTP::Raw) line 25 in method start at /home/todd/.perl6/sources/B0AFFC7E1CD3A465D71AF333700CF7086E4870E5 (Net::SMTP::Simple) line 63 in method new at /home/todd/.perl6/sources/AF0C4F60F05B28648456130019BA1D9C3B2FE938 (Net::SMTP) line 38 in block at ./crashme.pl6 line 16

And, my $client = Net::SMTP.new( :server( "smtp.zoho.com" ), :port( 465 ), :ssl, :simple, :debug( 1 ) );

$ crashme.pl6 err code: 336130329 error:1408F119:SSL routines:SSL3_GET_RECORD:decryption failed or bad record mac Use of uninitialized value of type Str in string context. Methods .^name, .perl, .gist, or .say can be used to stringify it to something meaningful. in method get-response at /home/todd/.perl6/sources/C7BFE131D057F94A1EC6C5CBF4DFC8C731D85400 (Net::SMTP::Raw) line 13 Start argument to substr out of range. Is: 3, should be in 0..0; use *-3 if you want to index relative to the end in method get-response at /home/todd/.perl6/sources/C7BFE131D057F94A1EC6C5CBF4DFC8C731D85400 (Net::SMTP::Raw) line 13 in method start at /home/todd/.perl6/sources/B0AFFC7E1CD3A465D71AF333700CF7086E4870E5 (Net::SMTP::Simple) line 59 in method new at /home/todd/.perl6/sources/AF0C4F60F05B28648456130019BA1D9C3B2FE938 (Net::SMTP) line 38 in block at ./crashme.pl6 line 17

ToddAndMargo commented 7 years ago

Workaround:

curl smtps://smtp.zoho.com:465 -v --mail-from "xxxxxxxxx@zoho.com" --mail-rcpt "yyyyyyyy@zoho.com" --ssl -u xxxxxxxxx@zoho.com:zzzzzzzzzzzzzz -T "mail.txt" -k --anyauth