aboutsummaryrefslogtreecommitdiffstats
path: root/vespaclient
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@verizonmedia.com>2019-07-16 18:01:09 +0200
committerBjørn Christian Seime <bjorncs@verizonmedia.com>2019-07-16 18:27:48 +0200
commitc083bf967b0697a0357035762b76956ebe5f0e59 (patch)
tree26676acc01c5fdbbc049a1b667235eae42e2f8e0 /vespaclient
parent40853cb3d5e7adbc90a03f29df217270cad4ec70 (diff)
Add https support to Perl http client
Diffstat (limited to 'vespaclient')
-rw-r--r--vespaclient/src/perl/lib/Yahoo/Vespa/Http.pm12
1 files changed, 11 insertions, 1 deletions
diff --git a/vespaclient/src/perl/lib/Yahoo/Vespa/Http.pm b/vespaclient/src/perl/lib/Yahoo/Vespa/Http.pm
index 3a32aa64d22..f0941b179d4 100644
--- a/vespaclient/src/perl/lib/Yahoo/Vespa/Http.pm
+++ b/vespaclient/src/perl/lib/Yahoo/Vespa/Http.pm
@@ -97,6 +97,15 @@ sub setHttpExecutor { # (Function)
sub initialize { # ()
%LEGAL_TYPES = map { $_ => 1 } ( 'GET', 'POST', 'PUT', 'DELETE');
$BROWSER = LWP::UserAgent->new;
+ if (defined $ENV{'VESPA_TLS_CA_CERT'}) {
+ $BROWSER->ssl_opts( SSL_ca_file => $ENV{'VESPA_TLS_CA_CERT'} );
+ }
+ if (defined $ENV{'VESPA_TLS_CERT'}) {
+ $BROWSER->ssl_opts( SSL_cert_file => $ENV{'VESPA_TLS_CERT'} );
+ }
+ if (defined $ENV{'VESPA_TLS_PRIVATE_KEY'}) {
+ $BROWSER->ssl_opts( SSL_key_file => $ENV{'VESPA_TLS_PRIVATE_KEY'} );
+ }
$BROWSER->agent('Vespa-perl-script');
$EXECUTE = \&execute;
}
@@ -146,7 +155,8 @@ sub execute { # (Type, Host, Port, Path, Params, Content, Headers) -> Response
}
sub buildUri { # (Host, Port, Path) -> UriString
my ($host, $port, $path) = @_;
- my $uri = "http:";
+ my $tls_enabled = $ENV{'VESPA_TLS_ENABLED'};
+ my $uri = (defined $tls_enabled and $tls_enabled eq '1') ? "https:" : "http:";
if (defined $host) {
$uri .= '//' . $host;
if (defined $port) {