From 05f33681cfe9d7c14c97ee6467881dda3128ac66 Mon Sep 17 00:00:00 2001 From: Kirill Solomko Date: Tue, 28 Jun 2016 12:06:07 +0200 Subject: [PATCH] MT#20341 add ssl_verify_loopback handling Change-Id: I0a254bb4c06cb4dc1250a86d83740b0ffb689027 --- lib/NGCP/API/Client.pm | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/NGCP/API/Client.pm b/lib/NGCP/API/Client.pm index 7178b93..77d8593 100644 --- a/lib/NGCP/API/Client.pm +++ b/lib/NGCP/API/Client.pm @@ -17,12 +17,14 @@ sub new { my $class = shift; my $self = {}; - $opts{host} = $cfg->{_}->{NGCP_API_IP}; - $opts{port} = $cfg->{_}->{NGCP_API_PORT}; - $opts{sslverify} = $cfg->{_}->{NGCP_API_SSLVERIFY} || 'yes'; - $opts{auth_user} = $cfg->{_}->{AUTH_SYSTEM_LOGIN}; - $opts{auth_pass} = $cfg->{_}->{AUTH_SYSTEM_PASSWORD}; - $opts{verbose} = 0; + $opts{host} = $cfg->{_}->{NGCP_API_IP}; + $opts{port} = $cfg->{_}->{NGCP_API_PORT}; + $opts{iface} = $cfg->{_}->{NGCP_API_IFACE}; + $opts{sslverify} = $cfg->{_}->{NGCP_API_SSLVERIFY} || 'yes'; + $opts{sslverify_lb} = $cfg->{_}->{NGCP_API_SSLVERIFY_LOOPBACK} || 'no'; + $opts{auth_user} = $cfg->{_}->{AUTH_SYSTEM_LOGIN}; + $opts{auth_pass} = $cfg->{_}->{AUTH_SYSTEM_PASSWORD}; + $opts{verbose} = 0; return bless $self, $class; } @@ -31,7 +33,8 @@ sub request { my ($self, $method, $uri, $data) = @_; my $ua = LWP::UserAgent->new(); - if ($opts{sslverify} eq 'no') { + if ($opts{sslverify} eq 'no' || + ($opts{sslverify_lb} eq 'no' && $opts{iface} =~ /^(lo|dummy)/)) { $ua->ssl_opts( verify_hostname => 0, SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE,