From bb4930dd27f1ce82e3d5adc9de18423f1c53e566 Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Thu, 5 Aug 2021 10:52:07 +0200 Subject: [PATCH] enh(3cx): support v18 (#3018) --- centreon-plugins/apps/voip/3cx/restapi/custom/api.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/centreon-plugins/apps/voip/3cx/restapi/custom/api.pm b/centreon-plugins/apps/voip/3cx/restapi/custom/api.pm index d415a57c4..9b518974b 100644 --- a/centreon-plugins/apps/voip/3cx/restapi/custom/api.pm +++ b/centreon-plugins/apps/voip/3cx/restapi/custom/api.pm @@ -122,7 +122,7 @@ sub settings { $self->build_options_for_httplib(); $self->{http}->add_header(key => 'Content-Type', value => 'application/json;charset=UTF-8'); if (defined($self->{cookie})) { - $self->{http}->add_header(key => 'Cookie', value => '.AspNetCore.Cookies=' . $self->{cookie}); + $self->{http}->add_header(key => 'Cookie', value => $self->{cookie}); if (defined($self->{xsrf})) { $self->{http}->add_header(key => 'X-XSRF-TOKEN', value => $self->{xsrf}); } @@ -153,7 +153,9 @@ sub authenticate { ); my $header = $self->{http}->get_header(name => 'Set-Cookie'); - if (defined ($header) && $header =~ /(?:^| ).AspNetCore.Cookies=([^;]+);.*/) { + # 3CX v16 cookie name is .AspNetCore.Cookies + # 3CX v18 cookie name is .AspNetCore.CookiesA + if (defined ($header) && $header =~ /(?:^| )(.AspNetCore.Cookies[A]?=[^;]+);.*/) { $cookie = $1; } else { $self->{output}->add_option_msg(short_msg => "Error retrieving cookie");