Sha256: c4d8b15e9aaeec829d7f566f1d0b247e45fb97eaddcb6b2c5000dade3d55afc1
Contents?: true
Size: 824 Bytes
Versions: 173
Compression:
Stored size: 824 Bytes
Contents
require 'openssl' require 'base64' module Cert class RhsmClient attr_accessor :cert def initialize(cert) self.cert = extract(cert) end def uuid drop_cn_prefix_from_subject(@cert.subject.to_s) end private def extract(cert) if cert.empty? fail('Invalid cert provided. Ensure that the provided cert is not empty.') else cert = strip_cert(cert) cert = Base64.decode64(cert) OpenSSL::X509::Certificate.new(cert) end end def drop_cn_prefix_from_subject(subject_string) subject_string.sub(/\/CN=/i, '') end def strip_cert(cert) cert = cert.to_s.gsub("-----BEGIN CERTIFICATE-----", "").gsub("-----END CERTIFICATE-----", "") cert.delete!(' ') cert.gsub!(/\n/, '') cert end end end
Version data entries
173 entries across 173 versions & 1 rubygems