Skip to content

Commit

Permalink
Move 'jwk' and 'alg' fields to protected header. (certbot#4677)
Browse files Browse the repository at this point in the history
* Move 'jwk' and 'alg' fields to protected header.

Previously, these were in the unprotected JWS header, which Boulder currently
allows. However, the next version of the spec doesn't allow anything in the
unprotected header. Moving these fields now allows server implementers who are
implementing the Certbot/Boulder version of ACME
(https://github.com/letsencrypt/boulder/blob/master/docs/acme-divergences.md) to
use JOSE libraries that don't support unprotected headers.

Fixes certbot#4417.

* Only protect existing headers.
  • Loading branch information
jsha authored and bmw committed May 17, 2017
1 parent 4caff11 commit 686f5d6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion acme/acme/jose/jws.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ def sign(cls, payload, key, alg, include_jwk=True,

protected_params = {}
for header in protect:
protected_params[header] = header_params.pop(header)
if header in header_params:
protected_params[header] = header_params.pop(header)
if protected_params:
# pylint: disable=star-args
protected = cls.header_cls(**protected_params).json_dumps()
Expand Down
2 changes: 1 addition & 1 deletion acme/acme/jws.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ def sign(cls, payload, key, alg, nonce, url=None, kid=None):
# jwk field if kid is not provided.
include_jwk = kid is None
return super(JWS, cls).sign(payload, key=key, alg=alg,
protect=frozenset(['nonce', 'url', 'kid']),
protect=frozenset(['nonce', 'url', 'kid', 'jwk', 'alg']),
nonce=nonce, url=url, kid=kid,
include_jwk=include_jwk)

0 comments on commit 686f5d6

Please sign in to comment.