2020-03-28 13:19:24 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'net/ldap/dn'
|
|
|
|
|
|
|
|
module X509Helper
|
|
|
|
def x509_subject(subject, search_keys)
|
|
|
|
subjects = {}
|
|
|
|
|
|
|
|
Net::LDAP::DN.new(subject).each_pair do |key, value|
|
|
|
|
if key.upcase.start_with?(*search_keys.map(&:upcase))
|
|
|
|
subjects[key.upcase] = value
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
subjects
|
2021-06-08 01:23:25 +05:30
|
|
|
rescue StandardError
|
2020-03-28 13:19:24 +05:30
|
|
|
{}
|
|
|
|
end
|
|
|
|
end
|