class Puppet::Util::Windows::RootCerts
Represents a collection of trusted root certificates.
@api public
Public Class Methods
instance()
click to toggle source
Returns a new instance. @return [Puppet::Util::Windows::RootCerts] object constructed from current root certificates
# File lib/puppet/util/windows/root_certs.rb 25 def self.instance 26 new(self.load_certs) 27 end
load_certs()
click to toggle source
Returns an array of root certificates.
@return [Array<>] an array of root certificates @api private
# File lib/puppet/util/windows/root_certs.rb 33 def self.load_certs 34 certs = [] 35 36 # This is based on a patch submitted to openssl: 37 # https://www.mail-archive.com/openssl-dev@openssl.org/msg26958.html 38 ptr = FFI::Pointer::NULL 39 store = CertOpenSystemStoreA(nil, "ROOT") 40 begin 41 while (ptr = CertEnumCertificatesInStore(store, ptr)) and not ptr.null? 42 context = CERT_CONTEXT.new(ptr) 43 cert_buf = context[:pbCertEncoded].read_bytes(context[:cbCertEncoded]) 44 begin 45 certs << OpenSSL::X509::Certificate.new(cert_buf) 46 rescue => detail 47 Puppet.warning(_("Failed to import root certificate: %{detail}") % { detail: detail.inspect }) 48 end 49 end 50 ensure 51 CertCloseStore(store, 0) 52 end 53 54 certs 55 end
new(roots)
click to toggle source
# File lib/puppet/util/windows/root_certs.rb 12 def initialize(roots) 13 @roots = roots 14 end
Public Instance Methods
each() { |cert| ... }
click to toggle source
Enumerates each root certificate. @yieldparam cert [OpenSSL::X509::Certificate] each root certificate @api public
# File lib/puppet/util/windows/root_certs.rb 19 def each 20 @roots.each {|cert| yield cert} 21 end