diff options
-rw-r--r-- | lib/chef/http/authenticator.rb | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/chef/http/authenticator.rb b/lib/chef/http/authenticator.rb index 6fbc2a74ba..c795297397 100644 --- a/lib/chef/http/authenticator.rb +++ b/lib/chef/http/authenticator.rb @@ -26,8 +26,6 @@ class Chef class HTTP class Authenticator DEFAULT_SERVER_API_VERSION = "2".freeze - # cspell:disable-next-line - SOME_CHARS = "~!@#%^&*_-+=`|\\(){}[<]:;'>,.?/0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".each_char.to_a extend Chef::Mixin::PowershellExec @@ -190,8 +188,9 @@ class Chef unless @win32registry.key_exists?(new_path) @win32registry.create_key(new_path, true) end + require "securerandom" unless defined?(SecureRandom) size = 14 - password = (0...size).map { SOME_CHARS[rand(SOME_CHARS.size)] }.join + password = SecureRandom.alphanumeric(size) encrypted_pass = encrypt_pfx_pass(password) values = { name: "PfxPass", type: :string, data: encrypted_pass } @win32registry.set_value(new_path, values) |