mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 20:55:44 +02:00
Fix REPP bulk renew SSL CA vericication
This commit is contained in:
parent
f80c597be8
commit
66f341dc85
1 changed files with 18 additions and 7 deletions
|
@ -10,13 +10,24 @@ class ReppApi
|
||||||
|
|
||||||
def self.request(request, uri, registrar:)
|
def self.request(request, uri, registrar:)
|
||||||
request.basic_auth(registrar.username, registrar.plain_text_password) if registrar
|
request.basic_auth(registrar.username, registrar.plain_text_password) if registrar
|
||||||
http = Net::HTTP.start(uri.hostname, uri.port, use_ssl: (uri.scheme == 'https'))
|
client_cert = Rails.env.test? ? nil : File.read(ENV['cert_path'])
|
||||||
unless Rails.env.test?
|
client_key = Rails.env.test? ? nil : File.read(ENV['key_path'])
|
||||||
http.cert = OpenSSL::X509::Certificate.new(File.read(ENV['cert_path']))
|
params = ReppApi.compose_ca_auth_params(uri, client_cert, client_key)
|
||||||
http.key = OpenSSL::PKey::RSA.new(File.read(ENV['key_path']))
|
|
||||||
end
|
|
||||||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if Rails.env.development? || Rails.env.test?
|
|
||||||
|
|
||||||
http.request(request)
|
Net::HTTP.start(uri.hostname, uri.port, params) do |http|
|
||||||
|
http.request(request)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.compose_ca_auth_params(uri, client_cert, client_key)
|
||||||
|
params = { use_ssl: (uri.scheme == 'https') }
|
||||||
|
params[:verify_mode] = OpenSSL::SSL::VERIFY_NONE if Rails.env.test? || Rails.env.development?
|
||||||
|
|
||||||
|
unless Rails.env.test?
|
||||||
|
params[:cert] = OpenSSL::X509::Certificate.new(client_cert)
|
||||||
|
params[:key] = OpenSSL::PKey::RSA.new(client_key)
|
||||||
|
end
|
||||||
|
|
||||||
|
params
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue