enh(protocol/x509): add ipv6 support for subjectAltNames (#2749)
This commit is contained in:
parent
2512ad1d8b
commit
7e308b0248
|
@ -23,6 +23,7 @@ package apps::protocols::x509::custom::file;
|
|||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::http;
|
||||
use Socket;
|
||||
use Net::SSLeay 1.42;
|
||||
use DateTime;
|
||||
|
||||
|
@ -130,7 +131,7 @@ sub read_certificate {
|
|||
for (my $i = 0; $i < $#subject_alt_names; $i += 2) {
|
||||
my ($type, $name) = ($subject_alt_names[$i], $subject_alt_names[$i + 1]);
|
||||
if ($type == &Net::SSLeay::GEN_IPADD) {
|
||||
$name = inet_ntoa($name);
|
||||
$name = Socket::inet_ntop(length($name) > 4 ? Socket::AF_INET6 : Socket::AF_INET, $name);
|
||||
}
|
||||
$cert_infos->{alt_subjects} .= $append . $name;
|
||||
$append = ', ';
|
||||
|
|
|
@ -25,6 +25,7 @@ use warnings;
|
|||
use centreon::plugins::http;
|
||||
use Net::SSLeay 1.42;
|
||||
use DateTime;
|
||||
use Socket;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
|
@ -119,7 +120,7 @@ sub pem_type {
|
|||
for (my $i = 0; $i < $#subject_alt_names; $i += 2) {
|
||||
my ($type, $name) = ($subject_alt_names[$i], $subject_alt_names[$i + 1]);
|
||||
if ($type == &Net::SSLeay::GEN_IPADD) {
|
||||
$name = inet_ntoa($name);
|
||||
$name = Socket::inet_ntop(length($name) > 4 ? Socket::AF_INET6 : Socket::AF_INET, $name);
|
||||
}
|
||||
$cert_infos->{alt_subjects} .= $append . $name;
|
||||
$append = ', ';
|
||||
|
@ -145,7 +146,7 @@ sub socket_type {
|
|||
for (my $i = 0; $i < $#subject_alt_names; $i += 2) {
|
||||
my ($type, $name) = ($subject_alt_names[$i], $subject_alt_names[$i + 1]);
|
||||
if ($type == &Net::SSLeay::GEN_IPADD) {
|
||||
$name = inet_ntoa($name);
|
||||
$name = Socket::inet_ntop(length($name) > 4 ? Socket::AF_INET6 : Socket::AF_INET, $name);
|
||||
}
|
||||
$cert_infos->{alt_subjects} .= $append . $name;
|
||||
$append = ', ';
|
||||
|
|
|
@ -217,7 +217,7 @@ sub get_certificate_informations {
|
|||
for (my $i = 0; $i < $#subject_alt_names; $i += 2) {
|
||||
my ($type, $name) = ($subject_alt_names[$i], $subject_alt_names[$i + 1]);
|
||||
if ($type == GEN_IPADD) {
|
||||
$name = inet_ntoa($name);
|
||||
$name = Socket::inet_ntop(length($name) > 4 ? Socket::AF_INET6 : Socket::AF_INET, $name);
|
||||
}
|
||||
$cert_infos->{alt_subjects} .= $append . $name;
|
||||
$append = ', ';
|
||||
|
|
Loading…
Reference in New Issue