diff options
author | danielsdeleo <dan@opscode.com> | 2012-12-12 11:29:19 -0800 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2012-12-12 13:26:17 -0800 |
commit | 5157e050becc85a01d9cd4f076c670b5f573e721 (patch) | |
tree | ef43997a8394a02f77d8ab09edfe6c51d39ecfcc /lib/chef/api_client.rb | |
parent | b0bd5359610355cb0c776e4de74cc0540042759b (diff) | |
download | chef-5157e050becc85a01d9cd4f076c670b5f573e721.tar.gz |
[CHEF-3662] ApiClient includes private key in JSON if present
After discussing with Adam and Seth F, there's no reason not to put the
private key in the serialized representation if we have it.
We ought to carefully review for behavior changes on the server side
before backporting to 10.x
Diffstat (limited to 'lib/chef/api_client.rb')
-rw-r--r-- | lib/chef/api_client.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/chef/api_client.rb b/lib/chef/api_client.rb index efb855b27a..b316e14f99 100644 --- a/lib/chef/api_client.rb +++ b/lib/chef/api_client.rb @@ -86,8 +86,8 @@ class Chef ) end - # The hash representation of the object. Includes the name and public_key, - # but never the private key. + # The hash representation of the object. Includes the name and public_key. + # Private key is included if available. # # @return [Hash] def to_hash @@ -98,6 +98,7 @@ class Chef 'json_class' => self.class.name, "chef_type" => "client" } + result["private_key"] = @private_key if @private_key result end @@ -111,7 +112,7 @@ class Chef def self.json_create(o) client = Chef::ApiClient.new client.name(o["name"] || o["clientname"]) - client.private_key(o["private_key"]) + client.private_key(o["private_key"]) if o.key?("private_key") client.public_key(o["public_key"]) client.admin(o["admin"]) client |