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 26 def self.instance 27 new(self.load_certs) 28 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 34 def self.load_certs 35 certs = [] 36 37 # This is based on a patch submitted to openssl: 38 # https://www.mail-archive.com/openssl-dev@openssl.org/msg26958.html 39 ptr = FFI::Pointer::NULL 40 store = CertOpenSystemStoreA(nil, "ROOT") 41 begin 42 while (ptr = CertEnumCertificatesInStore(store, ptr)) and not ptr.null? 43 context = CERT_CONTEXT.new(ptr) 44 cert_buf = context[:pbCertEncoded].read_bytes(context[:cbCertEncoded]) 45 begin 46 certs << OpenSSL::X509::Certificate.new(cert_buf) 47 rescue => detail 48 Puppet.warning(_("Failed to import root certificate: %{detail}") % { detail: detail.inspect }) 49 end 50 end 51 ensure 52 CertCloseStore(store, 0) 53 end 54 55 certs 56 end
new(roots)
click to toggle source
# File lib/puppet/util/windows/root_certs.rb 13 def initialize(roots) 14 @roots = roots 15 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 20 def each 21 @roots.each {|cert| yield cert} 22 end