Sha256: c15e2d7845d3de2ba90a6fc882a2977a18839a24991383308907b9b1db5c3890
Contents?: true
Size: 1.15 KB
Versions: 7
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true module Rails module Auth module X509 # X.509 client certificates obtained from HTTP requests class Certificate attr_reader :certificate def initialize(certificate) unless certificate.is_a?(OpenSSL::X509::Certificate) raise TypeError, "expecting OpenSSL::X509::Certificate, got #{certificate.class}" end @certificate = certificate.freeze @subject = {} @certificate.subject.to_a.each do |name, data, _type| @subject[name.freeze] = data.freeze end @subject.freeze end def [](component) @subject[component.to_s.upcase] end def cn @subject["CN".freeze] end alias common_name cn def ou @subject["OU".freeze] end alias organizational_unit ou # Generates inspectable attributes for debugging # # @return [Hash] hash containing parts of the certificate subject (cn, ou) def attributes { cn: cn, ou: ou } end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems