lib/acme/client.rb
# `force_chain_fingerprint` should be a SHA256 fingerprint of the expected CA in the chain.
# If both `force_chain` and `force_chain_fingerprint` are provided,
# `force_chain_fingerprint` takes precedence.
`force_chain_fingerprint` should be a SHA256 fingerprint of the expected CA in the chain.
` force_chain_fingerprint ` should be a SHA256 fingerprint of the expected CA in the chain .
def certificate(url:, force_chain: nil, force_chain_fingerprint: nil)
    response = download(url, format: :pem)
    pem = response.body
    return pem if force_chain.nil? && force_chain_fingerprint.nil?
    return pem if ChainIdentifier.new(pem)
                                 .match?(name: force_chain, fingerprint: force_chain_fingerprint)
       FaradayMiddlewaredecode_link_headers a single entry
       per rel= but nothing prevent it in the spec.
    alternative_urls = Array(response.headers.fetch(:link, {})['alternate'])
    alternative_urls.each do |alternate_url|
      response = download(alternate_url, format: :pem)
      pem = response.body
      if ChainIdentifier.new(pem).match?(name: force_chain, fingerprint: force_chain_fingerprint)
        return pem
      end
    end
    raise Acme::Client::Error::ForcedChainNotFound, "Could not find any matching chain for `{force_chain_fingerprint || force_chain}`"
  end
def certificate ( url : , force_chain : nil , force_chain_fingerprint : nil ) response = download ( url , format : :pem ) pem = response . body return pem if force_chain . nil? && force_chain_fingerprint . nil? return pem if ChainIdentifier . new ( pem ) . match? ( name : force_chain , fingerprint : force_chain_fingerprint ) alternative_urls = Array ( response . headers . fetch ( :link , { } ) [ 'alternate' ] ) alternative_urls . each do | alternate_url | response = download ( alternate_url , format : :pem ) pem = response . body if ChainIdentifier . new ( pem ) . match? ( name : force_chain , fingerprint : force_chain_fingerprint ) return pem end end raise Acme :: Client :: Error :: ForcedChainNotFound , "Could not find any matching chain for `#{force_chain_fingerprint || force_chain}`" end
`force_chain_fingerprint` should be a SHA256 fingerprint of the expected CA in the chain.
` force_chain_fingerprint ` should be a SHA256 fingerprint of the expected CA in the chain .
# TODO: Remove Array() after decode_link_headers fix # #   FaradayMiddleware#decode_link_headers a single entry #   per rel= but nothing prevent it in the spec.
url
force_chain
force_chain_fingerprint