knife-windows 3.0.6 → 3.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9432834ebf7782938c60391d85dc2af81228c917839f361692416ccf22659da7
4
- data.tar.gz: 129c34c1074fd2bfb7f3e3ac6b7c4a6cb160f74a23cc68f1f347e94dc8e58b1a
3
+ metadata.gz: 429cae6c473c57982b128b35647dc1616c0571bc24edce1a46b1eb3604700379
4
+ data.tar.gz: 4a99a1b6187c711adf545a8ce16e7f1fe9659751b39cedf0be96cbfb33eb2dc9
5
5
  SHA512:
6
- metadata.gz: bbc994bc3cbb06657e5ed5073a2a73d97623cc0c3d7d9b7365202a4a4bfd9df285fc475c5cf43ce6c95edbf9e5a08dc87c42b7665b5b5a4cb00260deb8ba41b1
7
- data.tar.gz: cedc907a3a7f52cab7bcfd8586dbfd2cfebac0081c135efc87d2d1a0428d8cb406c8371a4546c50d7bd8813b34f37d00a20f6b6f2dae709ca61aa68d7d942642
6
+ metadata.gz: cc0a6dc93a56a940f11bd5ff22774b0c02d799cb11465d523c18125335a708c7a50efa67fc63ac53e3325f8219305292fbb8abb5f2c4fabe8c5dbb38f5e4f3ec
7
+ data.tar.gz: 55a995dcd21e06fc8420f502f27d9fe7bacf2d4ded1a0c7e890bb3504fd9e4ce5b87f1b8aae43961c468232c24da861c3c458f9b9424edd39e02f5d00a974b75
@@ -16,11 +16,11 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'chef/knife'
20
- require 'chef/knife/bootstrap'
21
- require 'chef/encrypted_data_bag_item'
22
- require_relative 'knife_windows_base'
23
- require 'chef/util/path_helper'
19
+ require "chef/knife"
20
+ require "chef/knife/bootstrap"
21
+ require "chef/encrypted_data_bag_item"
22
+ require_relative "knife_windows_base"
23
+ require "chef/util/path_helper"
24
24
 
25
25
  class Chef
26
26
  class Knife
@@ -35,129 +35,130 @@ class Chef
35
35
  includer.class_eval do
36
36
 
37
37
  deps do
38
- require 'readline'
39
- require 'chef/json_compat'
38
+ require "readline"
39
+ require "chef/json_compat"
40
40
  end
41
41
 
42
42
  option :chef_node_name,
43
- :short => "-N NAME",
44
- :long => "--node-name NAME",
45
- :description => "The Chef node name for your new node"
43
+ short: "-N NAME",
44
+ long: "--node-name NAME",
45
+ description: "The Chef node name for your new node"
46
46
 
47
47
  option :prerelease,
48
- :long => "--prerelease",
49
- :description => "Install the pre-release chef gems"
48
+ long: "--prerelease",
49
+ description: "Install the pre-release chef gems"
50
50
 
51
51
  option :bootstrap_version,
52
- :long => "--bootstrap-version VERSION",
53
- :description => "The version of Chef to install",
54
- :proc => Proc.new { |v| Chef::Config[:knife][:bootstrap_version] = v }
52
+ long: "--bootstrap-version VERSION",
53
+ description: "The version of Chef to install",
54
+ proc: Proc.new { |v| Chef::Config[:knife][:bootstrap_version] = v }
55
55
 
56
56
  option :bootstrap_proxy,
57
- :long => "--bootstrap-proxy PROXY_URL",
58
- :description => "The proxy server for the node being bootstrapped",
59
- :proc => Proc.new { |p| Chef::Config[:knife][:bootstrap_proxy] = p }
57
+ long: "--bootstrap-proxy PROXY_URL",
58
+ description: "The proxy server for the node being bootstrapped",
59
+ proc: Proc.new { |p| Chef::Config[:knife][:bootstrap_proxy] = p }
60
60
 
61
61
  option :bootstrap_no_proxy,
62
- :long => "--bootstrap-no-proxy [NO_PROXY_URL|NO_PROXY_IP]",
63
- :description => "Do not proxy locations for the node being bootstrapped; this option is used internally by Opscode",
64
- :proc => Proc.new { |np| Chef::Config[:knife][:bootstrap_no_proxy] = np }
62
+ long: "--bootstrap-no-proxy [NO_PROXY_URL|NO_PROXY_IP]",
63
+ description: "Do not proxy locations for the node being bootstrapped; this option is used internally by Opscode",
64
+ proc: Proc.new { |np| Chef::Config[:knife][:bootstrap_no_proxy] = np }
65
65
 
66
66
  option :bootstrap_install_command,
67
- :long => "--bootstrap-install-command COMMANDS",
68
- :description => "Custom command to install chef-client",
69
- :proc => Proc.new { |ic| Chef::Config[:knife][:bootstrap_install_command] = ic }
67
+ long: "--bootstrap-install-command COMMANDS",
68
+ description: "Custom command to install chef-client",
69
+ proc: Proc.new { |ic| Chef::Config[:knife][:bootstrap_install_command] = ic }
70
70
 
71
71
  option :bootstrap_template,
72
- :short => "-t TEMPLATE",
73
- :long => "--bootstrap-template TEMPLATE",
74
- :description => "Bootstrap Chef using a built-in or custom template. Set to the full path of an erb template or use one of the built-in templates."
72
+ short: "-t TEMPLATE",
73
+ long: "--bootstrap-template TEMPLATE",
74
+ description: "Bootstrap Chef using a built-in or custom template. Set to the full path of an erb template or use one of the built-in templates."
75
75
 
76
76
  option :run_list,
77
- :short => "-r RUN_LIST",
78
- :long => "--run-list RUN_LIST",
79
- :description => "Comma separated list of roles/recipes to apply",
80
- :proc => lambda { |o| o.split(",") },
81
- :default => []
77
+ short: "-r RUN_LIST",
78
+ long: "--run-list RUN_LIST",
79
+ description: "Comma separated list of roles/recipes to apply",
80
+ proc: lambda { |o| o.split(",") },
81
+ default: []
82
82
 
83
83
  option :hint,
84
- :long => "--hint HINT_NAME[=HINT_FILE]",
85
- :description => "Specify Ohai Hint to be set on the bootstrap target. Use multiple --hint options to specify multiple hints.",
86
- :proc => Proc.new { |h|
87
- Chef::Config[:knife][:hints] ||= Hash.new
84
+ long: "--hint HINT_NAME[=HINT_FILE]",
85
+ description: "Specify Ohai Hint to be set on the bootstrap target. Use multiple --hint options to specify multiple hints.",
86
+ proc: Proc.new { |h|
87
+ Chef::Config[:knife][:hints] ||= {}
88
88
  name, path = h.split("=")
89
- Chef::Config[:knife][:hints][name] = path ? Chef::JSONCompat.parse(::File.read(path)) : Hash.new
89
+ Chef::Config[:knife][:hints][name] = path ? Chef::JSONCompat.parse(::File.read(path)) : {}
90
90
  }
91
91
 
92
92
  option :first_boot_attributes,
93
- :short => "-j JSON_ATTRIBS",
94
- :long => "--json-attributes",
95
- :description => "A JSON string to be added to the first run of chef-client",
96
- :proc => lambda { |o| JSON.parse(o) },
97
- :default => nil
93
+ short: "-j JSON_ATTRIBS",
94
+ long: "--json-attributes",
95
+ description: "A JSON string to be added to the first run of chef-client",
96
+ proc: lambda { |o| JSON.parse(o) },
97
+ default: nil
98
98
 
99
99
  option :first_boot_attributes_from_file,
100
- :long => "--json-attribute-file FILE",
101
- :description => "A JSON file to be used to the first run of chef-client",
102
- :proc => lambda { |o| Chef::JSONCompat.parse(File.read(o)) },
103
- :default => nil
100
+ long: "--json-attribute-file FILE",
101
+ description: "A JSON file to be used to the first run of chef-client",
102
+ proc: lambda { |o| Chef::JSONCompat.parse(File.read(o)) },
103
+ default: nil
104
104
 
105
105
  # Mismatch between option 'encrypted_data_bag_secret' and it's long value '--secret' is by design for compatibility
106
106
  option :encrypted_data_bag_secret,
107
- :short => "-s SECRET",
108
- :long => "--secret ",
109
- :description => "The secret key to use to decrypt data bag item values. Will be rendered on the node at c:/chef/encrypted_data_bag_secret and set in the rendered client config.",
110
- :default => false
107
+ short: "-s SECRET",
108
+ long: "--secret ",
109
+ description: "The secret key to use to decrypt data bag item values. Will be rendered on the node at c:/chef/encrypted_data_bag_secret and set in the rendered client config.",
110
+ default: false
111
111
 
112
112
  # Mismatch between option 'encrypted_data_bag_secret_file' and it's long value '--secret-file' is by design for compatibility
113
113
  option :encrypted_data_bag_secret_file,
114
- :long => "--secret-file SECRET_FILE",
115
- :description => "A file containing the secret key to use to encrypt data bag item values. Will be rendered on the node at c:/chef/encrypted_data_bag_secret and set in the rendered client config."
114
+ long: "--secret-file SECRET_FILE",
115
+ description: "A file containing the secret key to use to encrypt data bag item values. Will be rendered on the node at c:/chef/encrypted_data_bag_secret and set in the rendered client config."
116
116
 
117
117
  option :auth_timeout,
118
- :long => "--auth-timeout MINUTES",
119
- :description => "The maximum time in minutes to wait to for authentication over the transport to the node to succeed. The default value is 2 minutes.",
120
- :default => 2
118
+ long: "--auth-timeout MINUTES",
119
+ description: "The maximum time in minutes to wait to for authentication over the transport to the node to succeed. The default value is 2 minutes.",
120
+ default: 2
121
121
 
122
122
  option :node_ssl_verify_mode,
123
- :long => "--node-ssl-verify-mode [peer|none]",
124
- :description => "Whether or not to verify the SSL cert for all HTTPS requests.",
125
- :proc => Proc.new { |v|
126
- valid_values = ["none", "peer"]
123
+ long: "--node-ssl-verify-mode [peer|none]",
124
+ description: "Whether or not to verify the SSL cert for all HTTPS requests.",
125
+ proc: Proc.new { |v|
126
+ valid_values = %w{none peer}
127
127
  unless valid_values.include?(v)
128
128
  raise "Invalid value '#{v}' for --node-ssl-verify-mode. Valid values are: #{valid_values.join(", ")}"
129
129
  end
130
+
130
131
  v
131
132
  }
132
133
 
133
134
  option :node_verify_api_cert,
134
- :long => "--[no-]node-verify-api-cert",
135
- :description => "Verify the SSL cert for HTTPS requests to the Chef server API.",
136
- :boolean => true
135
+ long: "--[no-]node-verify-api-cert",
136
+ description: "Verify the SSL cert for HTTPS requests to the Chef server API.",
137
+ boolean: true
137
138
 
138
139
  option :msi_url,
139
- :short => "-u URL",
140
- :long => "--msi-url URL",
141
- :description => "Location of the Chef Client MSI. The default templates will prefer to download from this location. The MSI will be downloaded from chef.io if not provided.",
142
- :default => ''
140
+ short: "-u URL",
141
+ long: "--msi-url URL",
142
+ description: "Location of the Chef Client MSI. The default templates will prefer to download from this location. The MSI will be downloaded from chef.io if not provided.",
143
+ default: ""
143
144
 
144
145
  option :install_as_service,
145
- :long => "--install-as-service",
146
- :description => "Install chef-client as a Windows service",
147
- :default => false
146
+ long: "--install-as-service",
147
+ description: "Install chef-client as a Windows service",
148
+ default: false
148
149
 
149
150
  option :bootstrap_vault_file,
150
- :long => '--bootstrap-vault-file VAULT_FILE',
151
- :description => 'A JSON file with a list of vault(s) and item(s) to be updated'
151
+ long: "--bootstrap-vault-file VAULT_FILE",
152
+ description: "A JSON file with a list of vault(s) and item(s) to be updated"
152
153
 
153
154
  option :bootstrap_vault_json,
154
- :long => '--bootstrap-vault-json VAULT_JSON',
155
- :description => 'A JSON string with the vault(s) and item(s) to be updated'
155
+ long: "--bootstrap-vault-json VAULT_JSON",
156
+ description: "A JSON string with the vault(s) and item(s) to be updated"
156
157
 
157
158
  option :bootstrap_vault_item,
158
- :long => '--bootstrap-vault-item VAULT_ITEM',
159
- :description => 'A single vault and item to update as "vault:item"',
160
- :proc => Proc.new { |i|
159
+ long: "--bootstrap-vault-item VAULT_ITEM",
160
+ description: 'A single vault and item to update as "vault:item"',
161
+ proc: Proc.new { |i|
161
162
  (vault, item) = i.split(/:/)
162
163
  Chef::Config[:knife][:bootstrap_vault_item] ||= {}
163
164
  Chef::Config[:knife][:bootstrap_vault_item][vault] ||= []
@@ -166,20 +167,20 @@ class Chef
166
167
  }
167
168
 
168
169
  option :policy_name,
169
- :long => "--policy-name POLICY_NAME",
170
- :description => "Policyfile name to use (--policy-group must also be given)",
171
- :default => nil
170
+ long: "--policy-name POLICY_NAME",
171
+ description: "Policyfile name to use (--policy-group must also be given)",
172
+ default: nil
172
173
 
173
174
  option :policy_group,
174
- :long => "--policy-group POLICY_GROUP",
175
- :description => "Policy group name to use (--policy-name must also be given)",
176
- :default => nil
175
+ long: "--policy-group POLICY_GROUP",
176
+ description: "Policy group name to use (--policy-name must also be given)",
177
+ default: nil
177
178
 
178
179
  option :tags,
179
- :long => "--tags TAGS",
180
- :description => "Comma separated list of tags to apply to the node",
181
- :proc => lambda { |o| o.split(/[\s,]+/) },
182
- :default => []
180
+ long: "--tags TAGS",
181
+ description: "Comma separated list of tags to apply to the node",
182
+ proc: lambda { |o| o.split(/[\s,]+/) },
183
+ default: []
183
184
  end
184
185
  end
185
186
  end
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require_relative 'bootstrap_windows_base'
19
+ require_relative "bootstrap_windows_base"
20
20
 
21
21
  class Chef
22
22
  class Knife
@@ -25,11 +25,11 @@ class Chef
25
25
  include Chef::Knife::BootstrapWindowsBase
26
26
 
27
27
  deps do
28
- require 'chef/json_compat'
29
- require 'tempfile'
30
- require 'highline'
31
- require 'net/ssh'
32
- require 'net/ssh/multi'
28
+ require "chef/json_compat"
29
+ require "tempfile"
30
+ require "highline"
31
+ require "net/ssh"
32
+ require "net/ssh/multi"
33
33
  Chef::Knife::Ssh.load_deps
34
34
  Chef::Knife::Bootstrap.load_deps
35
35
  end
@@ -37,59 +37,59 @@ class Chef
37
37
  banner "knife bootstrap windows ssh FQDN (options)"
38
38
 
39
39
  option :ssh_user,
40
- :short => "-x USERNAME",
41
- :long => "--ssh-user USERNAME",
42
- :description => "The ssh username",
43
- :default => "root"
40
+ short: "-x USERNAME",
41
+ long: "--ssh-user USERNAME",
42
+ description: "The ssh username",
43
+ default: "root"
44
44
 
45
45
  option :ssh_password,
46
- :short => "-P PASSWORD",
47
- :long => "--ssh-password PASSWORD",
48
- :description => "The ssh password"
46
+ short: "-P PASSWORD",
47
+ long: "--ssh-password PASSWORD",
48
+ description: "The ssh password"
49
49
 
50
50
  option :ssh_port,
51
- :short => "-p PORT",
52
- :long => "--ssh-port PORT",
53
- :description => "The ssh port",
54
- :proc => Proc.new { |key| Chef::Config[:knife][:ssh_port] = key.strip }
51
+ short: "-p PORT",
52
+ long: "--ssh-port PORT",
53
+ description: "The ssh port",
54
+ proc: Proc.new { |key| Chef::Config[:knife][:ssh_port] = key.strip }
55
55
 
56
56
  option :ssh_gateway,
57
- :short => "-G GATEWAY",
58
- :long => "--ssh-gateway GATEWAY",
59
- :description => "The ssh gateway",
60
- :proc => Proc.new { |key| Chef::Config[:knife][:ssh_gateway] = key }
57
+ short: "-G GATEWAY",
58
+ long: "--ssh-gateway GATEWAY",
59
+ description: "The ssh gateway",
60
+ proc: Proc.new { |key| Chef::Config[:knife][:ssh_gateway] = key }
61
61
 
62
62
  option :forward_agent,
63
- :short => "-A",
64
- :long => "--forward-agent",
65
- :description => "Enable SSH agent forwarding",
66
- :boolean => true
63
+ short: "-A",
64
+ long: "--forward-agent",
65
+ description: "Enable SSH agent forwarding",
66
+ boolean: true
67
67
 
68
68
  option :identity_file,
69
- :long => "--identity-file IDENTITY_FILE",
70
- :description => "The SSH identity file used for authentication. [DEPRECATED] Use --ssh-identity-file instead."
69
+ long: "--identity-file IDENTITY_FILE",
70
+ description: "The SSH identity file used for authentication. [DEPRECATED] Use --ssh-identity-file instead."
71
71
 
72
72
  option :ssh_identity_file,
73
- :short => "-i IDENTITY_FILE",
74
- :long => "--ssh-identity-file IDENTITY_FILE",
75
- :description => "The SSH identity file used for authentication"
73
+ short: "-i IDENTITY_FILE",
74
+ long: "--ssh-identity-file IDENTITY_FILE",
75
+ description: "The SSH identity file used for authentication"
76
76
 
77
77
  option :host_key_verify,
78
- :long => "--[no-]host-key-verify",
79
- :description => "Verify host key, enabled by default.",
80
- :boolean => true,
81
- :default => true
78
+ long: "--[no-]host-key-verify",
79
+ description: "Verify host key, enabled by default.",
80
+ boolean: true,
81
+ default: true
82
82
 
83
83
  def run
84
- Chef::Application.fatal!(<<~EOM
85
- *knife windows bootstrap ssh*
86
- Core Chef now supports bootstrapping Windows systems without a knife plugin
87
-
88
- Use 'knife bootstrap -o ssh' instead.
89
-
90
- For more detail https://github.com/chef/chef/blob/master/RELEASE_NOTES.md#knife-bootstrap
91
- EOM
92
- )
84
+ Chef::Application.fatal!(<<~EOM
85
+ *knife windows bootstrap ssh*
86
+ Core Chef now supports bootstrapping Windows systems without a knife plugin
87
+
88
+ Use 'knife bootstrap -o ssh' instead.
89
+
90
+ For more detail https://github.com/chef/chef/blob/master/RELEASE_NOTES.md#knife-bootstrap
91
+ EOM
92
+ )
93
93
  end
94
94
 
95
95
  end
@@ -16,11 +16,10 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require_relative 'bootstrap_windows_base'
20
- require_relative 'winrm'
21
- require_relative 'winrm_base'
22
- require_relative 'winrm_knife_base'
23
-
19
+ require_relative "bootstrap_windows_base"
20
+ require_relative "winrm"
21
+ require_relative "winrm_base"
22
+ require_relative "winrm_knife_base"
24
23
 
25
24
  class Chef
26
25
  class Knife
@@ -31,24 +30,24 @@ class Chef
31
30
  include Chef::Knife::WinrmCommandSharedFunctions
32
31
 
33
32
  deps do
34
- require 'chef/json_compat'
35
- require 'tempfile'
33
+ require "chef/json_compat"
34
+ require "tempfile"
36
35
  Chef::Knife::Winrm.load_deps
37
36
  Chef::Knife::Bootstrap.load_deps
38
37
  end
39
38
 
40
- banner 'knife bootstrap windows winrm FQDN (options)'
39
+ banner "knife bootstrap windows winrm FQDN (options)"
41
40
 
42
41
  def run
43
- Chef::Application.fatal!(<<~EOM
44
- *knife windows bootstrap winrm*
45
- Core Chef now supports bootstrapping Windows systems without a knife plugin
46
-
47
- Use 'knife bootstrap -o winrm' instead.
48
-
49
- For more detail https://github.com/chef/chef/blob/master/RELEASE_NOTES.md#knife-bootstrap
50
- EOM
51
- )
42
+ Chef::Application.fatal!(<<~EOM
43
+ *knife windows bootstrap winrm*
44
+ Core Chef now supports bootstrapping Windows systems without a knife plugin
45
+
46
+ Use 'knife bootstrap -o winrm' instead.
47
+
48
+ For more detail https://github.com/chef/chef/blob/master/RELEASE_NOTES.md#knife-bootstrap
49
+ EOM
50
+ )
52
51
  end
53
52
 
54
53
  end
@@ -30,4 +30,3 @@ class Chef
30
30
  end
31
31
  end
32
32
  end
33
-
@@ -15,10 +15,10 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require 'chef/knife'
19
- require_relative 'winrm_base'
20
- require 'openssl'
21
- require 'socket'
18
+ require "chef/knife"
19
+ require_relative "winrm_base"
20
+ require "openssl"
21
+ require "socket"
22
22
 
23
23
  class Chef
24
24
  class Knife
@@ -29,34 +29,34 @@ class Chef
29
29
  banner "knife windows cert generate FILE_PATH (options)"
30
30
 
31
31
  option :hostname,
32
- :short => "-H HOSTNAME",
33
- :long => "--hostname HOSTNAME",
34
- :description => "Use to specify the hostname for the listener.
32
+ short: "-H HOSTNAME",
33
+ long: "--hostname HOSTNAME",
34
+ description: "Use to specify the hostname for the listener.
35
35
  For example, --hostname something.mydomain.com or *.mydomain.com.",
36
- :required => true
36
+ required: true
37
37
 
38
38
  option :output_file,
39
- :short => "-o PATH",
40
- :long => "--output-file PATH",
41
- :description => "Specifies the file path at which to generate the 3 certificate files of type .pfx, .b64, and .pem. The default is './winrmcert'.",
42
- :default => "winrmcert"
39
+ short: "-o PATH",
40
+ long: "--output-file PATH",
41
+ description: "Specifies the file path at which to generate the 3 certificate files of type .pfx, .b64, and .pem. The default is './winrmcert'.",
42
+ default: "winrmcert"
43
43
 
44
44
  option :key_length,
45
- :short => "-k LENGTH",
46
- :long => "--key-length LENGTH",
47
- :description => "Default is 2048",
48
- :default => "2048"
45
+ short: "-k LENGTH",
46
+ long: "--key-length LENGTH",
47
+ description: "Default is 2048",
48
+ default: "2048"
49
49
 
50
50
  option :cert_validity,
51
- :short => "-cv MONTHS",
52
- :long => "--cert-validity MONTHS",
53
- :description => "Default is 24 months",
54
- :default => "24"
51
+ short: "-cv MONTHS",
52
+ long: "--cert-validity MONTHS",
53
+ description: "Default is 24 months",
54
+ default: "24"
55
55
 
56
56
  option :cert_passphrase,
57
- :short => "-cp PASSWORD",
58
- :long => "--cert-passphrase PASSWORD",
59
- :description => "Password for certificate."
57
+ short: "-cp PASSWORD",
58
+ long: "--cert-passphrase PASSWORD",
59
+ description: "Password for certificate."
60
60
 
61
61
  def generate_keypair
62
62
  OpenSSL::PKey::RSA.new(config[:key_length].to_i)
@@ -69,16 +69,17 @@ class Chef
69
69
  print "Enter certificate passphrase (empty for no passphrase):"
70
70
  passphrase = STDIN.gets
71
71
  return passphrase.strip if passphrase == "\n"
72
+
72
73
  print "Enter same passphrase again:"
73
74
  confirm_passphrase = STDIN.gets
74
75
  end until passphrase == confirm_passphrase
75
76
  passphrase.strip
76
77
  end
77
78
 
78
- def generate_certificate rsa_key
79
+ def generate_certificate(rsa_key)
79
80
  @hostname = config[:hostname] if config[:hostname]
80
81
 
81
- #Create a self-signed X509 certificate from the rsa_key (unencrypted)
82
+ # Create a self-signed X509 certificate from the rsa_key (unencrypted)
82
83
  cert = OpenSSL::X509::Certificate.new
83
84
  cert.version = 2
84
85
  cert.serial = Random.rand(65534) + 1 # 2 digit byte range random number for better security aspect
@@ -91,8 +92,8 @@ class Chef
91
92
  ef = OpenSSL::X509::ExtensionFactory.new
92
93
  ef.subject_certificate = cert
93
94
  ef.issuer_certificate = cert
94
- cert.add_extension(ef.create_extension("subjectKeyIdentifier","hash",false))
95
- cert.add_extension(ef.create_extension("authorityKeyIdentifier","keyid:always",false))
95
+ cert.add_extension(ef.create_extension("subjectKeyIdentifier", "hash", false))
96
+ cert.add_extension(ef.create_extension("authorityKeyIdentifier", "keyid:always", false))
96
97
  cert.add_extension(ef.create_extension("extendedKeyUsage", "1.3.6.1.5.5.7.3.1", false))
97
98
  cert.sign(rsa_key, OpenSSL::Digest::SHA1.new)
98
99
  @thumbprint = OpenSSL::Digest::SHA1.new(cert.to_der)
@@ -110,7 +111,7 @@ class Chef
110
111
  def certificates_already_exist?(file_path)
111
112
  certs_exists = false
112
113
  %w{pem pfx b64}.each do |extn|
113
- if !Dir.glob("#{file_path}.*#{extn}").empty?
114
+ unless Dir.glob("#{file_path}.*#{extn}").empty?
114
115
  certs_exists = true
115
116
  break
116
117
  end
@@ -119,7 +120,7 @@ class Chef
119
120
  if certs_exists
120
121
  begin
121
122
  confirm("Do you really want to overwrite existing certificates")
122
- rescue SystemExit # Need to handle this as confirming with N/n raises SystemExit exception
123
+ rescue SystemExit # Need to handle this as confirming with N/n raises SystemExit exception
123
124
  exit!
124
125
  end
125
126
  end
@@ -129,7 +130,7 @@ class Chef
129
130
  STDOUT.sync = STDERR.sync = true
130
131
 
131
132
  # takes user specified first cli value as a destination file path for generated cert.
132
- file_path = @name_args.empty? ? config[:output_file].sub(/\.(\w+)$/,'') : @name_args.first
133
+ file_path = @name_args.empty? ? config[:output_file].sub(/\.(\w+)$/, "") : @name_args.first
133
134
 
134
135
  # check if certs already exists at given file path
135
136
  certificates_already_exist? file_path
@@ -152,4 +153,3 @@ class Chef
152
153
  end
153
154
  end
154
155
  end
155
-