Method: Chef::Client#check_certstore_for_key

Defined in:
lib/chef/client.rb

#check_certstore_for_key(cert_name) ⇒ Object

In the brave new world of No Certs On Disk, we want to put the pem file into Keychain or the Certstore But is it already there? We’re solving the multi-user scenario where both a system/admin user can run on the box but also someone without admin rights can also run correctly locally.



673
674
675
676
677
678
679
680
681
# File 'lib/chef/client.rb', line 673

def check_certstore_for_key(cert_name)
  require "win32-certstore"
  if Chef::Config[:auth_key_registry_type] == "user"
    win32certstore = ::Win32::Certstore.open("MY", store_location: CERT_SYSTEM_STORE_CURRENT_USER)
  else
    win32certstore = ::Win32::Certstore.open("MY")
  end
  win32certstore.search("#{cert_name}")
end