]> git.proxmox.com Git - pve-manager.git/commitdiff
API2Client: allow to set ssl options
authorDietmar Maurer <dietmar@proxmox.com>
Sun, 13 Nov 2016 08:51:57 +0000 (09:51 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Sun, 13 Nov 2016 08:51:57 +0000 (09:51 +0100)
and use /etc/pve/pve-root-ca.pem as default CA.

PVE/API2Client.pm

index e58e9a21d4c8757e26dc9eb741250888815d2a7e..a68c766f0b9ea1646556da83745e0f0ac6df2871 100755 (executable)
@@ -155,6 +155,12 @@ sub call {
 sub new {
     my ($class, %param) = @_;
 
+    my $default_ca = "/etc/pve/pve-root-ca.pem";
+
+    my $ssl_default_opts = {  verify_hostname => 0 };
+    $ssl_default_opts->{SSL_ca_file} = $default_ca
+       if -f $default_ca;
+
     my $self = { 
        ticket => $param{ticket},
        csrftoken => $param{csrftoken},
@@ -163,6 +169,7 @@ sub new {
        host => $param{host} || 'localhost',
        port => $param{port},
        protocol => $param{protocol},
+       ssl_opts => $param{ssl_opts} || $ssl_default_opts,
        timeout => $param{timeout} || 60,
     };
     bless $self;
@@ -181,7 +188,7 @@ sub new {
     $self->{useragent} = LWP::UserAgent->new(
        cookie_jar => $self->{cookie_jar},
        protocols_allowed => [ 'http', 'https'],
-       ssl_opts => { verify_hostname => 0 },
+       ssl_opts => $self->{ssl_opts},
        timeout => $self->{timeout},
        );