Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add secure(-S) and disable hostname validation(-i) options for opensearch script #515

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions snmp/opensearch
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Supported command line options are as below.
Default: 127.0.0.1
-p <port> The port to use.
Default: 9200
-S Use https instead of http.
-I Do not verify hostname (when used with -S).
-P Pretty print.
-S Use HTTPS.

Expand Down Expand Up @@ -65,17 +67,19 @@ sub main::HELP_MESSAGE {
. " Default: 127.0.0.1\n"
. "-p <port> The port to use.\n"
. " Default: 9200\n"
. "-P Pretty print.\n"
. "-S Use HTTPS.\n";
. "-S Use https instead of http.\n"
. "-I Do not verify hostname (when used with -S).\n"
. "-P Pretty print.\n";
}

my $protocol = 'http';
my $host = '127.0.0.1';
my $port = 9200;
my $schema = 'http';

#gets the options
my %opts;
getopts( 'a:c:h:p:P:S', \%opts );
getopts( 'a:c:h:p:PIS', \%opts );
if ( defined( $opts{h} ) ) {
$host = $opts{h};
}
Expand Down Expand Up @@ -112,6 +116,12 @@ if ( $opts{P} ) {

my $ua = LWP::UserAgent->new( timeout => 10 );

if ( $opts{I} ) {
$ua->ssl_opts( verify_hostname => 0, SSL_verify_mode => 0x00 );
}

my $stats_response = $ua->get($stats_url);

if ( defined( $opts{c} ) ) {
# set ca file
$ua->ssl_opts( SSL_ca_file => $opts{c});
Expand Down
Loading