From: Ivan Kohler Date: Sat, 2 Apr 2016 21:39:32 +0000 (-0700) Subject: really don't verify certificates if asked, deb 8 style X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=820906c790f19828477eabd37218c71c2a724d86 really don't verify certificates if asked, deb 8 style --- diff --git a/FS/FS/Misc/Geo.pm b/FS/FS/Misc/Geo.pm index 73122fa66..92490bb3b 100644 --- a/FS/FS/Misc/Geo.pm +++ b/FS/FS/Misc/Geo.pm @@ -6,6 +6,7 @@ use vars qw( $DEBUG @EXPORT_OK $conf ); use LWP::UserAgent; use HTTP::Request; use HTTP::Request::Common qw( GET POST ); +use IO::Socket::SSL; use HTML::TokeParser; use Cpanel::JSON::XS; use URI::Escape 3.31; @@ -655,7 +656,12 @@ sub standardize_freeside { return $location; } - my $ua = LWP::UserAgent->new( 'ssl_opts' => { 'verify_hostname'=>0 }); + my $ua = LWP::UserAgent->new( + 'ssl_opts' => { + verify_hostname => 0, + SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE, + }, + ); my $response = $ua->request( POST $url, [ 'support-key' => scalar($conf->config('support-key')), %$location, @@ -666,7 +672,10 @@ sub standardize_freeside { local $@; my $content = eval { decode_json($response->content) }; - die "Address normalization JSON error : $@\n" if $@; + if ( $@ ) { + warn $response->content; + die "Address normalization JSON error : $@\n"; + } die $content->{error}."\n" if $content->{error}; diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm index a82d51deb..df1b86d7c 100644 --- a/FS/FS/Template_Mixin.pm +++ b/FS/FS/Template_Mixin.pm @@ -2375,6 +2375,7 @@ service. =cut use CAM::PDF; +use IO::Socket::SSL; use LWP::UserAgent; use HTTP::Request::Common qw( POST ); use Cpanel::JSON::XS; @@ -2415,7 +2416,12 @@ sub postal_mail_fsinc { my $file = $self->print_pdf(%opt, 'no_addresses' => 1); my $pages = CAM::PDF->new($file)->numPages; - my $ua = LWP::UserAgent->new( 'ssl_opts' => { 'verify_hostname'=>0 }); + my $ua = LWP::UserAgent->new( + 'ssl_opts' => { + verify_hostname => 0, + SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE, + } + ); my $response = $ua->request( POST $url, [ 'support-key' => scalar($conf->config('support-key')), 'file' => encode_base64($file), diff --git a/FS/FS/part_event/Action/http.pm b/FS/FS/part_event/Action/http.pm index 673cd4356..72a345d6b 100644 --- a/FS/FS/part_event/Action/http.pm +++ b/FS/FS/part_event/Action/http.pm @@ -4,6 +4,7 @@ use base qw( FS::part_event::Action ); use strict; use vars qw( $me ); use Data::Dumper; +use IO::Socket::SSL; use LWP::UserAgent; use HTTP::Request::Common; use Cpanel::JSON::XS; @@ -68,10 +69,17 @@ sub do_action { ( $field, $value ); } split(/\n/, $self->option('content') ); + if ( $self->option('debug') ) { + warn "[$me] $_: ". $content{$_}. "\n" foreach keys %content; + } + my $content = encode_json( \%content ); my @lwp_opts = (); - push @lwp_opts, 'ssl_opts'=>{ 'verify_hostname'=>0 } + push @lwp_opts, 'ssl_opts' => { + verify_hostname => 0, + SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE, + } if $self->option('ssl_no_verify'); my $ua = LWP::UserAgent->new(@lwp_opts); @@ -82,7 +90,7 @@ sub do_action { ); if ( $self->option('debug') ) { - + #XXX dump raw request for debugging } my $response = $ua->request($req); diff --git a/FS/FS/part_export/http.pm b/FS/FS/part_export/http.pm index 6cac60058..42a35cb07 100644 --- a/FS/FS/part_export/http.pm +++ b/FS/FS/part_export/http.pm @@ -3,6 +3,9 @@ package FS::part_export::http; use base qw( FS::part_export ); use vars qw( %options %info ); use Tie::IxHash; +use LWP::UserAgent; +use HTTP::Request::Common qw( POST ); +use IO::Socket::SSL; tie %options, 'Tie::IxHash', 'method' => { label =>'Method', @@ -149,13 +152,12 @@ sub http { $method = lc($method); - eval "use LWP::UserAgent;"; - die "using LWP::UserAgent: $@" if $@; - eval "use HTTP::Request::Common;"; - die "using HTTP::Request::Common: $@" if $@; - my @lwp_opts = (); - push @lwp_opts, 'ssl_opts'=>{ 'verify_hostname'=>0 } if $ssl_no_verify; + push @lwp_opts, 'ssl_opts' => { + verify_hostname => 0, + SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE, + } + if $ssl_no_verify; my $ua = LWP::UserAgent->new(@lwp_opts); #my $response = $ua->$method( diff --git a/FS/FS/part_export/ispconfig3.pm b/FS/FS/part_export/ispconfig3.pm index 3345b3f06..9d22d1995 100644 --- a/FS/FS/part_export/ispconfig3.pm +++ b/FS/FS/part_export/ispconfig3.pm @@ -6,6 +6,7 @@ use base qw( FS::part_export ); use Data::Dumper; use SOAP::Lite; +use IO::Socket::SSL; =pod @@ -299,7 +300,12 @@ sub api_login { } $self->{'__ispconfig_session'} = undef; $self->{'__ispconfig_client'} = - SOAP::Lite->proxy($self->option('soap_location'), ssl_opts => [ verify_hostname => 0 ] ) + SOAP::Lite->proxy( $self->option('soap_location'), + ssl_opts => [ + verify_hostname => 0, + SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE, + ] + ) || undef; unless ($self->{'__ispconfig_client'}) { $self->{'__ispconfig_error'} = 'Error creating SOAP client'; diff --git a/FS/FS/part_export/sipwise.pm b/FS/FS/part_export/sipwise.pm index 8fec01300..9d4e3366e 100644 --- a/FS/FS/part_export/sipwise.pm +++ b/FS/FS/part_export/sipwise.pm @@ -5,6 +5,7 @@ use strict; use FS::Record qw(qsearch qsearchs dbh); use Tie::IxHash; +use IO::Socket::SSL; use LWP::UserAgent; use URI; use Cpanel::JSON::XS; @@ -801,7 +802,10 @@ sub ua { $self->{_ua} ||= do { my @opt; if ( $self->option('ssl_no_verify') ) { - push @opt, ssl_opts => { verify_hostname => 0 }; + push @opt, ssl_opts => { + verify_hostname => 0, + SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE, + }; } my $ua = LWP::UserAgent->new(@opt); $ua->credentials(