diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Control/Dahua.pm b/scripts/ZoneMinder/lib/ZoneMinder/Control/Dahua.pm index ec9b20901..0cd7af1f4 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Control/Dahua.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Control/Dahua.pm @@ -91,6 +91,7 @@ sub open ); $self->{ua}->agent("ZoneMinder Control Agent/".ZoneMinder::Base::ZM_VERSION); $self->{state} = 'closed'; + $self->{ssl_verified} = 1; # Track if we're using SSL verification # credentials: ("ip:port" (no prefix!), realm (string), username (string), password (string) $self->{ua}->credentials($ADDRESS, $REALM, $USERNAME, $PASSWORD); @@ -100,13 +101,14 @@ sub open my $res = $self->{ua}->request($req); # If SSL verification failed, retry without verification - if (!$res->is_success && $res->status_line =~ /SSL|certificate|verify/i) { + if (!$res->is_success && $self->{ssl_verified} && $res->status_line =~ /SSL|certificate|verify/i) { Warning("SSL certificate verification failed for $url (" . $res->status_line . "), retrying without verification"); $self->{ua}->ssl_opts( verify_hostname => 0, SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE, SSL_hostname => '' ); + $self->{ssl_verified} = 0; $res = $self->{ua}->request($req); } @@ -185,6 +187,18 @@ sub _sendGetRequest { my $req = HTTP::Request->new(GET => $url); my $res = $self->{ua}->request($req); + # If SSL verification failed, retry without verification + if (!$res->is_success && $self->{ssl_verified} && $res->status_line =~ /SSL|certificate|verify/i) { + Warning("SSL certificate verification failed for $url (" . $res->status_line . "), retrying without verification"); + $self->{ua}->ssl_opts( + verify_hostname => 0, + SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE, + SSL_hostname => '' + ); + $self->{ssl_verified} = 0; + $res = $self->{ua}->request($req); + } + if ($res->is_success) { return 1; } else { diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Control/TapoC520WS_ONVIF.pm b/scripts/ZoneMinder/lib/ZoneMinder/Control/TapoC520WS_ONVIF.pm index 48f9ea3de..51d4d0ed2 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Control/TapoC520WS_ONVIF.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Control/TapoC520WS_ONVIF.pm @@ -229,7 +229,6 @@ sub sendCmd { # If SSL verification failed, retry without verification if (!$res->is_success && $self->{ssl_verified} && $res->status_line =~ /SSL|certificate|verify/i) { Warning("SSL certificate verification failed for $server_endpoint (" . $res->status_line . "), retrying without verification"); - use IO::Socket::SSL; $self->{ua}->ssl_opts( verify_hostname => 0, SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE, @@ -273,7 +272,6 @@ sub getCamParams { # If SSL verification failed, retry without verification if (!$res->is_success && $self->{ssl_verified} && $res->status_line =~ /SSL|certificate|verify/i) { Warning("SSL certificate verification failed for $server_endpoint (" . $res->status_line . "), retrying without verification"); - use IO::Socket::SSL; $self->{ua}->ssl_opts( verify_hostname => 0, SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE,