Commit f86e44e7 authored by Ahmad Hassan's avatar Ahmad Hassan

Deduplicate certificates

parent d6886506
...@@ -26,6 +26,7 @@ module Gitlab ...@@ -26,6 +26,7 @@ module Gitlab
end end
end end
PEM_REXP = /[-]+BEGIN CERTIFICATE[-]+.+?[-]+END CERTIFICATE[-]+/m
SERVER_VERSION_FILE = 'GITALY_SERVER_VERSION' SERVER_VERSION_FILE = 'GITALY_SERVER_VERSION'
MAXIMUM_GITALY_CALLS = 35 MAXIMUM_GITALY_CALLS = 35
CLIENT_NAME = (Sidekiq.server? ? 'gitlab-sidekiq' : 'gitlab-web').freeze CLIENT_NAME = (Sidekiq.server? ? 'gitlab-sidekiq' : 'gitlab-web').freeze
...@@ -62,9 +63,18 @@ module Gitlab ...@@ -62,9 +63,18 @@ module Gitlab
cert_paths = Dir["#{OpenSSL::X509::DEFAULT_CERT_DIR}/*"] cert_paths = Dir["#{OpenSSL::X509::DEFAULT_CERT_DIR}/*"]
cert_paths << OpenSSL::X509::DEFAULT_CERT_FILE if File.exist? OpenSSL::X509::DEFAULT_CERT_FILE cert_paths << OpenSSL::X509::DEFAULT_CERT_FILE if File.exist? OpenSSL::X509::DEFAULT_CERT_FILE
@certs = cert_paths.map do |cert| @certs = []
File.read(cert) cert_paths.each do |cert_file|
end.join("\n") begin
File.read(cert_file).scan(PEM_REXP).each do |cert|
pem = OpenSSL::X509::Certificate.new(cert).to_pem
@certs << pem
end
rescue StandardError => e
Rails.logger.error "Could not load certificate #{e}"
end
end
@certs = @certs.uniq.join "\n"
end end
def self.stub_creds(storage) def self.stub_creds(storage)
......
Markdown is supported
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