From 6fef2c0b62dd5e21b7b7fcb02b9a2639632662b9 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Tue, 21 Aug 2018 04:39:49 -0700 Subject: Only try to set the default keys if there is a default value to set. Signed-off-by: Noah Kantrowitz --- chef-config/lib/chef-config/workstation_config_loader.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/chef-config/lib/chef-config/workstation_config_loader.rb b/chef-config/lib/chef-config/workstation_config_loader.rb index 65940102fc..af0c438ca1 100644 --- a/chef-config/lib/chef-config/workstation_config_loader.rb +++ b/chef-config/lib/chef-config/workstation_config_loader.rb @@ -225,12 +225,14 @@ module ChefConfig Config[:node_name] ||= Etc.getlogin # If we don't have a key (path or inline) check user.pem and $node_name.pem. unless Config.key?(:client_key) || Config.key?(:client_key_contents) - Config[:client_key] = find_default_key(["#{Config[:node_name]}.pem", "user.pem"]) + key_path = find_default_key(["#{Config[:node_name]}.pem", "user.pem"]) + Config[:client_key] = key_path if key_path end # Similarly look for a validation key file, though this should be less # common these days. unless Config.key?(:validation_key) || Config.key?(:validation_key_contents) - Config[:validation_key] = find_default_key(["#{Config[:validation_client_name]}.pem", "validator.pem", "validation.pem"]) + key_path = find_default_key(["#{Config[:validation_client_name]}.pem", "validator.pem", "validation.pem"]) + Config[:validation_key] = key_path if key_path end end -- cgit v1.2.1 From fda14962c003f6f43d1a2656951dfebccf0845c4 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Tue, 21 Aug 2018 04:40:03 -0700 Subject: Check for an actual value, rather than the key being set. Signed-off-by: Noah Kantrowitz --- lib/chef/knife/core/bootstrap_context.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb index 4e21564c52..5c736ab01b 100644 --- a/lib/chef/knife/core/bootstrap_context.rb +++ b/lib/chef/knife/core/bootstrap_context.rb @@ -45,7 +45,7 @@ class Chef end def validation_key - if @chef_config.key?(:validation_key) && + if @chef_config[:validation_key] && File.exist?(File.expand_path(@chef_config[:validation_key])) IO.read(File.expand_path(@chef_config[:validation_key])) else -- cgit v1.2.1