Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for PKCS8 SHA1 fingerprints #159

Merged
merged 1 commit into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/chef/resource/chef_acl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def rest_url(path)
end

def rest_list(path)
# All our rest lists are hashes where the keys are the names
# All our rest lists are hashes where the keys are the names
[ rest.get(rest_url(path)).keys, nil ]
rescue Net::HTTPServerException => e
if e.response.code == "405" || e.response.code == "404"
Expand Down
11 changes: 1 addition & 10 deletions lib/cheffish/key_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,7 @@ def self.encode(key, key_format)
hexes = Digest::MD5.hexdigest(data)
hexes.scan(/../).join(":")
when :pkcs8sha1fingerprint
if RUBY_VERSION.to_f >= 2.0
raise "PKCS8 SHA1 not supported in Ruby #{RUBY_VERSION}"
end

require "openssl_pkcs8"
pkcs8_pem = key.to_pem_pkcs8
pkcs8_base64 = pkcs8_pem.split("\n").reject { |l| l =~ /^-----/ }
pkcs8_data = Base64.decode64(pkcs8_base64.join)
hexes = Digest::SHA1.hexdigest(pkcs8_data)
hexes.scan(/../).join(":")
raise "PKCS8 SHA1 not supported by Ruby 2.0 and later"
else
raise "Unrecognized key format #{format}"
end
Expand Down
6 changes: 2 additions & 4 deletions spec/functional/fingerprint_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ def key_to_format(key, format)

context "when computing key fingperprints" do

it "computes the PKCS#8 SHA1 private key fingerprint correctly", pending: (RUBY_VERSION.to_f >= 2.0) do
expect(key_to_format(sample_private_key, :pkcs8sha1fingerprint)).to eq(
"88:7e:3a:bd:26:9f:b5:c5:d8:ae:52:f9:df:0b:64:a4:5c:17:0a:87"
)
it "raises when passing a PKCS#8 SHA1 private key fingerprint" do
expect { key_to_format(sample_private_key, :pkcs8sha1fingerprint) }.to raise_error
end

it "computes the PKCS#1 MD5 public key fingerprint correctly" do
Expand Down