class Cert::RhsmClient
Attributes
cert[RW]
Public Class Methods
new(cert)
click to toggle source
# File lib/smart_proxy_container_gateway/rhsm_client.rb, line 8 def initialize(cert) self.cert = extract(cert) end
Public Instance Methods
uuid()
click to toggle source
# File lib/smart_proxy_container_gateway/rhsm_client.rb, line 12 def uuid @uuid ||= @cert.subject.to_a.find { |entry| entry[0] == 'CN' }&.[](1) end
Private Instance Methods
extract(cert)
click to toggle source
# File lib/smart_proxy_container_gateway/rhsm_client.rb, line 18 def extract(cert) raise('Invalid cert provided. Ensure that the provided cert is not empty.') if cert.empty? cert = strip_cert(cert) cert = Base64.decode64(cert) OpenSSL::X509::Certificate.new(cert) end
strip_cert(cert)
click to toggle source
# File lib/smart_proxy_container_gateway/rhsm_client.rb, line 26 def strip_cert(cert) cert = cert.to_s.gsub("-----BEGIN CERTIFICATE-----", "").gsub("-----END CERTIFICATE-----", "") cert.delete!(' ') cert.delete!("\n") cert end