Skip to content

Commit 1c2029f

Browse files
committed
Fix certificate sending
1 parent a370e78 commit 1c2029f

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

app/models/foreman_rh_cloud/ping.rb

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ class Ping
44
FAIL_RETURN_CODE = 'FAIL'.freeze
55

66
SERVICE_URLS = {
7-
:advisor => "http://localhost:24443/api/insights/v1/status/live/",
8-
:vulnerabilities => "http://localhost:24443/api/insights/v1/status/live/"
7+
:advisor => "https://localhost:24443/api/insights/v1/status/live/",
8+
:vulnerability => "https://localhost:24443/api//api/vulnerability/v1/apistatus"
99
}
1010

1111
class << self
@@ -60,11 +60,19 @@ def ping_url(url)
6060

6161
options = {}
6262
options[:ssl_ca_file] = ca_file unless ca_file.nil?
63-
# options[:headers] = { 'Correlation-ID' => request_id } if request_id
63+
options[:ssl_client_cert] = OpenSSL::X509::Certificate.new(File.read(Setting[:ssl_certificate]))
64+
options[:ssl_client_key] = OpenSSL::PKey.read(File.read(Setting[:ssl_priv_key]))
65+
6466
client = RestClient::Resource.new(url, options)
6567

6668
response = client.get
67-
response.empty? ? {} : JSON.parse(response).with_indifferent_access
69+
return {} if response.empty?
70+
begin
71+
result = JSON.parse(response).with_indifferent_access
72+
rescue JSON::ParserError, NoMethodError
73+
result = { :response => response.body&.strip }
74+
end
75+
result
6876
end
6977

7078
def ping_service(service_name, service_result_hash)
@@ -74,4 +82,4 @@ def ping_service(service_name, service_result_hash)
7482
end
7583
end
7684
end
77-
end
85+
end

0 commit comments

Comments
 (0)