Sha256: 338a58c7bbdd04940e47b48c18f73e64337529a1308729925b0deb7468e1455a

Contents?: true

Size: 909 Bytes

Versions: 7

Compression:

Stored size: 909 Bytes

Contents

module Acme::Client::Util
  def urlsafe_base64(data)
    Base64.urlsafe_encode64(data).sub(/[\s=]*\z/, '')
  end

  LINK_MATCH = /<(.*?)>\s?;\s?rel="([\w-]+)"/

  # See RFC 8288 - https://tools.ietf.org/html/rfc8288#section-3
  def decode_link_headers(link_header)
    link_header.split(',').each_with_object({}) { |entry, hash|
      _, link, name = *entry.match(LINK_MATCH)
      hash[name] ||= []
      hash[name].push(link)
    }
  end

  # Sets public key on CSR or cert.
  #
  # obj  - An OpenSSL::X509::Certificate or OpenSSL::X509::Request instance.
  # priv - An OpenSSL::PKey::EC or OpenSSL::PKey::RSA instance.
  #
  # Returns nothing.
  def set_public_key(obj, priv)
    case priv
    when OpenSSL::PKey::EC
      obj.public_key = priv
    when OpenSSL::PKey::RSA
      obj.public_key = priv.public_key
    else
      raise ArgumentError, 'priv must be EC or RSA'
    end
  end

  extend self
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
acme-client-2.0.13 lib/acme/client/util.rb
acme-client-2.0.12 lib/acme/client/util.rb
acme-client-2.0.11 lib/acme/client/util.rb
acme-client-2.0.10 lib/acme/client/util.rb
acme-client-2.0.9 lib/acme/client/util.rb
acme-client-2.0.8 lib/acme/client/util.rb
acme-client-2.0.7 lib/acme/client/util.rb