Commit 6eb87885 authored by Côme Bernigaud's avatar Côme Bernigaud Committed by Benoit Mortier
Browse files

Fixes #4046 argonaut-fai-monitor does not work with HTTPS

parent 218fd124
......@@ -719,6 +719,7 @@ sub argonaut_get_server_settings {
'keyfile' => "argonautKeyPath",
'certfile' => "argonautCertPath",
'cacertfile' => "argonautCaCertPath",
'certcn' => "argonautCertCN",
'iptool' => "argonautIpTool",
'delete_finished_tasks' => "argonautDeleteFinished",
'fetch_packages' => "argonautFetchPackages",
......
......@@ -95,20 +95,10 @@ sub get_id
{
my $host = shift;
unless (exists $taskids{$host}) {
my $client;
if (USE_LEGACY_JSON_RPC) {
$client = new JSON::RPC::Legacy::Client;
} else {
$client = new JSON::RPC::Client;
}
$client->version('1.0');
my $callobj = {
method => "get_host_id",
params => [$host, '(objectClass=FAIobject)'],
};
my $taskid = $client->call($protocol."://".$config->{'server_ip'}.":".$server_port, $callobj);
my $taskid = rpc_call(
"get_host_id",
[$host, '(objectClass=FAIobject)']
);
if($taskid) {
if ($taskid->is_error) {
......@@ -117,7 +107,7 @@ sub get_id
$taskids{$host} = $taskid->content->{result};
}
} else {
die "Error while trying to contact Argonaut server : ".$client->status_line."\n";
die "Error while trying to contact Argonaut server\n";
}
}
return $taskids{$host};
......@@ -135,9 +125,13 @@ sub rpc_call
}
$client->version('1.0');
if ($protocol eq 'https') {
#~ if ($client->ua->can('ssl_opts')) {
#~ $client->ua->ssl_opts(verify_hostname => 1, SSL_ca_file => "dummy_ca.crt");
#~ }
if ($client->ua->can('ssl_opts')) {
$client->ua->ssl_opts(
verify_hostname => 1,
SSL_ca_file => $client_settings->{'cacertfile'},
SSL_verifycn_name => $server_settings->{'certcn'}
);
}
$client->ua->credentials($config->{'server_ip'}.":".$server_port, "JSONRPCRealm", "", argonaut_gen_ssha_token($server_settings->{'token'}));
}
......@@ -157,6 +151,8 @@ sub rpc_call
$log->error("Error while trying to contact Argonaut server : ".$client->status_line);
print "Error while trying to contact Argonaut server : ".$client->status_line."\n";
}
return $res;
}
sub parse_line
......
......@@ -134,8 +134,8 @@ sub launch { # if ip pings, send the request
SSL_ca_file => $self->{'cacertfile'},
SSL_verifycn_name => $self->{'certcn'}
);
$client->ua->credentials($ip.":".$self->{'port'}, "JSONRPCRealm", "", argonaut_gen_ssha_token($self->{'token'}));
}
$client->ua->credentials($ip.":".$self->{'port'}, "JSONRPCRealm", "", argonaut_gen_ssha_token($self->{'token'}));
}
my $callobj = {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment