Sha256: cdd9baad2758ce3832618e630eaa13648fbc996fe221898ae4ff175a5f91f1fe

Contents?: true

Size: 586 Bytes

Versions: 2

Compression:

Stored size: 586 Bytes

Contents

class Acme::Crypto
  attr_reader :private_key

  def initialize(private_key)
    @private_key = private_key
  end

  def generate_signed_jws(header:, payload:)
    jwt = JSON::JWT.new(payload || {})
    jwt.header.merge!(header || {})
    jwt.header[:jwk] = jwk
    jwt.signature = jwt.sign(private_key, :RS256).signature
    jwt.to_json(syntax: :flattened)
  end

  def jwk
    @jwk ||= JSON::JWK.new(public_key)
  end

  def thumbprint
    jwk.thumbprint
  end

  def public_key
    @public_key ||= private_key.public_key
  end

  def digest
    OpenSSL::Digest::SHA256.new
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
acme-client-0.2.2 lib/acme/crypto.rb
acme-client-0.2.1 lib/acme/crypto.rb