fix: Address code review feedback
- Add SSL verification state tracking to Dahua.pm to ensure retry logic works for all requests - Add SSL retry logic to Dahua.pm sendCmd method - Remove redundant 'use IO::Socket::SSL' statements from TapoC520WS_ONVIF.pm retry blocks refs #TBD Co-authored-by: connortechnology <925519+connortechnology@users.noreply.github.com>copilot/enable-tls-verification
parent
3d8399bfab
commit
27793980ef
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue