16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/smart_proxy_pulp_plugin/pulp_client.rb', line 16
def self.http
uri = URI.parse(::PulpProxy::Settings.settings.pulp_url.to_s)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == 'https'
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
if http.use_ssl?
if Proxy::SETTINGS.ssl_ca_file && !Proxy::SETTINGS.ssl_ca_file.to_s.empty?
http.ca_file = Proxy::SETTINGS.ssl_ca_file
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
end
if Proxy::SETTINGS.ssl_certificate && !Proxy::SETTINGS.ssl_certificate.to_s.empty? && Proxy::SETTINGS.ssl_private_key && !Proxy::SETTINGS.ssl_private_key.to_s.empty?
http.cert = OpenSSL::X509::Certificate.new(File.read(Proxy::SETTINGS.ssl_certificate))
http.key = OpenSSL::PKey::RSA.new(File.read(Proxy::SETTINGS.ssl_private_key), nil)
end
end
http
end
|