Project

General

Profile

« Previous | Next » 

Revision d0097f65

Added by Martin Milata over 9 years ago

Extract and send subjectAltName from client cert

Related to https://bugzilla.redhat.com/show_bug.cgi?id=1161120

View differences:

lib/smart_proxy_abrt/abrt_lib.rb
response
end
def self.common_name(request)
def self.cert_names(request)
client_cert = request.env['SSL_CLIENT_CERT']
raise AbrtProxy::Error::Unauthorized, "Client certificate required" if client_cert.to_s.empty?
......
raise AbrtProxy::Error::CertificateError, e.message
end
cn = client_cert.subject.to_a.detect { |name, value| name == 'CN' }
cn = cn[1] unless cn.nil?
raise AbrtProxy::Error::CertificateError, "Common Name not found in the certificate" unless cn
begin
cn = client_cert.subject.to_a.find { |name, value| name == 'CN' }
names = [cn[1]]
rescue NoMethodError
raise AbrtProxy::Error::CertificateError, "Common Name not found in the certificate"
end
alt_name_ext = client_cert.extensions.find { |ext| ext.oid == 'subjectAltName' }
if alt_name_ext
names += alt_name_ext.value.
split(/, ?/).
select { |s| s.start_with? 'URI:CN=' }.
map { |s| s.sub(/^URI:CN=/, '') }
end
return cn
return names
end
class AbrtRequest < Proxy::HttpRequest::ForemanRequest
......
@by_hash[hash] = ar unless hash.nil?
@files = [fname]
@host = json["host"]
@althosts = json["althosts"]
end
def merge(other)
......
end
end
def self.save(host, report, reported_at=nil)
def self.save(hostnames, report, reported_at=nil)
# create the spool dir if it does not exist
FileUtils.mkdir_p HostReport.spooldir
reported_at ||= Time.now.utc
on_disk_report = { "host" => host, "report" => report , "reported_at" => reported_at.to_s }
on_disk_report = { "host" => hostnames[0], "report" => report , "reported_at" => reported_at.to_s, "althosts" => hostnames[1..-1] }
# write report to temporary file
temp_fname = unique_filename "new-"
......
def create_foreman_report
{ "abrt_report" => {
"host" => @host,
"althosts" => @althosts,
"reports" => format_reports
}
}

Also available in: Unified diff