1
0
mirror of https://github.com/c-kr/check_json.git synced 2024-11-23 19:03:49 +01:00

Add CA cert option

This commit is contained in:
Herman van Rink 2021-05-15 22:43:32 +02:00
parent 36f30b8151
commit 2d14c35db8
No known key found for this signature in database
GPG Key ID: 9D317CDE2CCC962F

View File

@ -18,6 +18,7 @@ my $np = Nagios::Plugin->new(
. "[ -d|--divisor <divisor> ] " . "[ -d|--divisor <divisor> ] "
. "[ -m|--metadata <content> ] " . "[ -m|--metadata <content> ] "
. "[ -T|--contenttype <content-type> ] " . "[ -T|--contenttype <content-type> ] "
. "[ --cacert ] "
. "[ --client-cert ] " . "[ --client-cert ] "
. "[ --private-key ] " . "[ --private-key ] "
. "[ --ignoressl ] " . "[ --ignoressl ] "
@ -95,6 +96,12 @@ $np->add_arg(
help => "-T, --contenttype application/json \n " help => "-T, --contenttype application/json \n "
. "Content-type accepted if different from application/json ", . "Content-type accepted if different from application/json ",
); );
$np->add_arg(
spec => 'cacert|C=s',
default => '',
help => "-T, --cacert /foo/ca.crt \n "
. "Ca certificate ",
);
$np->add_arg( $np->add_arg(
spec => 'client-cert|J=s', spec => 'client-cert|J=s',
default => '', default => '',
@ -130,6 +137,9 @@ $ua->timeout($np->opts->timeout);
if ($np->opts->ignoressl) { if ($np->opts->ignoressl) {
$ua->ssl_opts(verify_hostname => 0, SSL_verify_mode => 0x00); $ua->ssl_opts(verify_hostname => 0, SSL_verify_mode => 0x00);
} }
if ($np->opts->{'cacert'}) {
$ua->ssl_opts(SSL_ca_file => $np->opts->{'cacert'});
}
if ($np->opts->httpclientcert) { if ($np->opts->httpclientcert) {
$ua->ssl_opts( $ua->ssl_opts(
SSL_cert_file => $np->opts->httpclientcert, SSL_cert_file => $np->opts->httpclientcert,