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