lib/acme/client/jwk/base.rb in acme-client-1.0.0 vs lib/acme/client/jwk/base.rb in acme-client-2.0.0
- old
+ new
@@ -13,11 +13,11 @@
# header - A Hash of extra header fields to include.
# payload - A Hash of payload data.
#
# Returns a JSON String.
def jws(header: {}, payload: {})
- header = jws_header.merge(header)
+ header = jws_header(header)
encoded_header = Acme::Client::Util.urlsafe_base64(header.to_json)
encoded_payload = Acme::Client::Util.urlsafe_base64(payload.to_json)
signature_data = "#{encoded_header}.#{encoded_payload}"
signature = sign(signature_data)
@@ -54,15 +54,16 @@
# Header fields for a JSON web signature.
#
# typ: - Value for the `typ` field. Default 'JWT'.
#
# Returns a Hash.
- def jws_header
- {
+ def jws_header(header)
+ jws = {
typ: 'JWT',
- alg: jwa_alg,
- jwk: to_h
- }
+ alg: jwa_alg
+ }.merge(header)
+ jws[:jwk] = to_h if header[:kid].nil?
+ jws
end
# The name of the algorithm as needed for the `alg` member of a JWS object.
#
# Returns a String.