Sha256: b53ad54db4a86dce9dcefc7efca383f8087cd16eea9af26b4e02b50459439018
Contents?: true
Size: 962 Bytes
Versions: 3
Compression:
Stored size: 962 Bytes
Contents
class Acme::Crypto attr_reader :private_key def initialize(private_key) @private_key = private_key end def generate_signed_jws(header:, payload:) protection_header = generate_protection_header(header) payload = encode64(JSON.dump(payload)) JSON.dump( { header: { alg: :RS256, jwk: jwk }, protected: protection_header, payload: payload, signature: generate_signature(protection_header, payload) } ) end def generate_signature(protection_header, payload) input = "#{protection_header}.#{payload}" signature = private_key.sign(digest, input) encode64(signature) end def generate_protection_header(header) encode64(JSON.dump(header)) end def jwk JSON::JWK.new(public_key).to_hash end def public_key private_key.public_key end def digest OpenSSL::Digest::SHA256.new end def encode64(input) UrlSafeBase64.encode64(input) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
acme-client-0.1.2 | lib/acme/crypto.rb |
acme-client-0.1.1 | lib/acme/crypto.rb |
acme-client-0.1.0 | lib/acme/crypto.rb |