Welcome to mirror list, hosted at ThFree Co, Russian Federation.

x509_helper.rb « helpers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 599be0b91f74baf2700776a36d5b3bd85e65780b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 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
  rescue StandardError
    {}
  end
end