Skip to content

Commit

Permalink
Merge pull request #54 from sorah/ossl3
Browse files Browse the repository at this point in the history
Support OpenSSL 3
  • Loading branch information
sorah authored Oct 8, 2022
2 parents d4a84fe + 6405785 commit 56fbbbf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby-version: ['2.6', '2.7']
ruby-version: ['2.7', '3.0', '3.1']
container:
image: sorah/ruby:${{ matrix.ruby-version }}-dev
image: public.ecr.aws/sorah/ruby:${{ matrix.ruby-version }}-dev
steps:

- name: Cache bundled gems
Expand All @@ -40,7 +40,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby-version: ['2.6', '2.7']
ruby-version: ['2.7', '3.0', '3.1']

# FIXME: once GitHub Actions gains support of adding command line arguments to container
# services:
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:

- run: 'docker run -d --net=host --rm letsencrypt/pebble pebble -config /test/config/pebble-config.json -strict -dnsserver 127.0.0.1:8053'
- run: 'docker run -d --net=host --rm letsencrypt/pebble-challtestsrv pebble-challtestsrv -management :8055 -defaultIPv4 127.0.0.1'
- run: 'docker run --net=host -e CI --rm -v $(pwd):/work -v $(realpath ~/bundle):/bundle sorah/ruby:${{ matrix.ruby-version }}-dev sh -c "cd /work && bundle install --path /bundle && bundle exec rspec -fd -t integration_pebble"'
- run: 'docker run --net=host -e CI --rm -v $(pwd):/work -v $(realpath ~/bundle):/bundle public.ecr.aws/sorah/ruby:${{ matrix.ruby-version }}-dev sh -c "cd /work && bundle install --path /bundle && bundle exec rspec -fd -t integration_pebble"'

docker-build:
name: docker-build
Expand Down
27 changes: 20 additions & 7 deletions lib/acmesmith/certificate_retrieving_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ def match?(name: nil, key_id: nil)

if key_id
top_key_id = if has_root
top.extensions.find { |e| e.oid == 'subjectKeyIdentifier' }.value
value_der(top.extensions.find { |e| e.oid == 'subjectKeyIdentifier' })&.slice(2..-1)
else
top.extensions.find { |e| e.oid == 'authorityKeyIdentifier' }.value&.each_line&.grep(/^keyid:/)&.first&.yield_self { |v| v[6..-1] }&.chomp
end
return false unless key_id.downcase == top_key_id.downcase
value_der(top.extensions.find { |e| e.oid == 'authorityKeyIdentifier' })&.slice(4,20)
end&.unpack1('H*')&.downcase
return false unless key_id.downcase.gsub(/:/,'') == top_key_id
end

true
Expand All @@ -97,12 +97,25 @@ def top
private def find_issuer(cert)
return nil if cert.issuer == cert.subject

aki = cert.extensions.find { |e| e.oid == 'authorityKeyIdentifier' }.value&.each_line&.grep(/^keyid:/)&.first&.yield_self { |v| v[6..-1] }&.chomp
# https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.1
# sequence(\x30\x16) context-specific(\x80\x14) + keyid
aki = value_der(cert.extensions.find { |e| e.oid == 'authorityKeyIdentifier' })

# compare using SKI as a AKI DER. this doesn't support AKI using other than keyid but it should be okay
certificates.find do |c|
ski = c.extensions.find { |e| e.oid == 'subjectKeyIdentifier' }.value
ski == aki && cert.issuer == c.subject
ski_der = value_der(c.extensions.find { |e| e.oid == 'subjectKeyIdentifier' })
next unless ski_der
hdr = "\x30\x16\x80\x14".b
keyid = ski_der[2..-1]

"#{hdr}#{keyid}" == aki && cert.issuer == c.subject
end
end

private def value_der(ext)
return nil unless ext
ext.respond_to?(:value_der) ? ext.value_der : ext.to_der[9..-1]
end
end

private def download(url, format:)
Expand Down

0 comments on commit 56fbbbf

Please sign in to comment.