Skip to content
Snippets Groups Projects
Commit fa358f2ce46d authored by Kenneth Chu's avatar Kenneth Chu
Browse files

Refactor key size comparison to be more efficient

parent fc1c18ccac94
No related branches found
No related tags found
2 merge requests!51Validate shift of Heptapod 0.25 to oldstable series,!44GitLab 14.0
......@@ -21,8 +21,9 @@
# they provide invalid data
helper = LetsEncryptHelper.new(node)
contact_info = helper.contact
target_key_size = new_resource.key_size || node['acme']['key_size']
if ::File.file?("#{new_resource.key}-staging")
staging_key = OpenSSL::PKey::RSA.new ::File.read "#{new_resource.key}-staging"
staging_key_size = staging_key.n.num_bits
......@@ -24,18 +25,9 @@
if ::File.file?("#{new_resource.key}-staging")
staging_key = OpenSSL::PKey::RSA.new ::File.read "#{new_resource.key}-staging"
staging_key_size = staging_key.n.num_bits
if new_resource.key_size.nil?
unless staging_key_size == node['acme']['key_size']
file "#{new_resource.key}-staging" do
action :delete
end
file "#{new_resource.crt}-staging" do
action :delete
end
end
elsif staging_key_size != new_resource.key_size
if staging_key_size != target_key_size
file "#{new_resource.key}-staging" do
action :delete
end
......@@ -70,16 +62,7 @@
production_key = OpenSSL::PKey::RSA.new ::File.read new_resource.key
production_key_size = production_key.n.num_bits
if new_resource.key_size.nil?
unless production_key_size == node['acme']['key_size']
file new_resource.key do
action :delete
end
file new_resource.crt do
action :delete
end
end
elsif production_key_size != new_resource.key_size
if production_key_size != target_key_size
file new_resource.key do
action :delete
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment