Re: [jose] Question regarding RFC 7515

Anders Rundgren <> Sat, 05 December 2020 04:56 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id 85ED13A0B74 for <>; Fri, 4 Dec 2020 20:56:27 -0800 (PST)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -2.099
X-Spam-Status: No, score=-2.099 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: (amavisd-new); dkim=pass (2048-bit key)
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id VRD230KINu9A for <>; Fri, 4 Dec 2020 20:56:25 -0800 (PST)
Received: from ( [IPv6:2a00:1450:4864:20::333]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by (Postfix) with ESMTPS id 86D203A0B71 for <>; Fri, 4 Dec 2020 20:56:25 -0800 (PST)
Received: by with SMTP id f190so8798129wme.1 for <>; Fri, 04 Dec 2020 20:56:25 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=8CSgfNba7GIfqKRu0iVZtIUcsKTcvEZibGavgsnpEuQ=; b=PcR0zhUy/SgMxUxGUv8pSqeydVgOW5fEKkmb2UU4YX0yap1qSqbV0CX5FbmH1/OgbH siv0paZxqFS/RtarFA+PihYeUIzmxUIGTQo816YaxHP4N33xogGeklwnaGQ0LSs6/AvQ sPSfq+mxGQOaJ0LNyylldpjY9qkVkjs8dr7eu6+tgn/CfwWSG28Ey+5U9ITfTSg5gv6H 2VgZtF1+t2/mZGALk8iS95RhYLt1YV7cD8Ka6KwtQRyEIUeEjAmk8/0+/tmv4XGtjEZy b/V68SGJyDFEQ714gRJh0TzG+XMeWUthlTsTk9BwoQ2gGSCq9Xmtu1QHjX6ciC6lRCdI y2xQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=8CSgfNba7GIfqKRu0iVZtIUcsKTcvEZibGavgsnpEuQ=; b=VX9ZXci29XZ0aoGP7F/8DD+UlqBPVUYYhNM+NyFmlhsDrH+9fbVQs7bATroUVv9Okg 12jzhc/iKGqmGdovm/8mdmKnXj4A7iXaa4TxUrPjUYsBNQTFP6XD3uvY+IkFrRol+tY5 Tk51l67vL+TBgFSrj8net+eaBrz8o19ERzwIA98Xffu2evqEleYIwM4/vbYK+V+v9zgg mYXhT8rtWmhg2QAYpkl8q4+yQ1dHkjZLUE1S+W7sv+jEndGQSK6VfZE1m7ADZUwLpl+W Kin4TcJtn1+rOEEbIBoacPNOcmJyrVrq/MLxlYKVvFdBjSoe4V028Uj0eCFqp0FqjGv0 peOg==
X-Gm-Message-State: AOAM531eYuKU8IjsVC4Jr/fJCG0ztUoXTgHFLj0BDsOXByGOB/skHjX/ +jVx5vBSofQIg2LQr126nSb6wOE1WOawtA==
X-Google-Smtp-Source: ABdhPJywTHzCsqJ3T+6eBtndJ3n/KXO6U+bMZ+y2T+crUP9OwGMf/xN+S25btgIItcaiIo/twUv5sw==
X-Received: by 2002:a7b:c2e8:: with SMTP id e8mr7334627wmk.103.1607144182868; Fri, 04 Dec 2020 20:56:22 -0800 (PST)
Received: from [] ( []) by with ESMTPSA id y68sm4620402wmc.0.2020. (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Dec 2020 20:56:22 -0800 (PST)
To: Arshad Noor <>,
References: <>
From: Anders Rundgren <>
Message-ID: <>
Date: Sat, 5 Dec 2020 05:56:19 +0100
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1
MIME-Version: 1.0
In-Reply-To: <>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Archived-At: <>
Subject: Re: [jose] Question regarding RFC 7515
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Javascript Object Signing and Encryption <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-Subscribe: <>, <>
X-List-Received-Date: Sat, 05 Dec 2020 04:56:28 -0000

On 2020-12-02 04:26, Arshad Noor wrote:
> Hi,

Hi Arshad,

> I have a few questions on the use of the "x5c" header parameter for
> which there is insufficient guidance.
> 1) Section 4.1.6 (X.509 Certificate Chain) states that the "..chain is
> represented as a JSON array..". However, it is not clear whether a
> single certificate still needs to be enclosed within an array if one is
> using a self-signed certificate, and when using "Flattened JWS JSON
> Serialization Syntax".

It is always an array of JSON strings (=certificates).

> 2) Section 6 (Key Identification) states that "..Header parameters ..
> "x5c" .. MUST be integrity protected if the information to be
> utilized in a trust decision. I take this to read that, when using the
> flattened JWS JSON serialization, "x5c" must be included in the
> "protected" attribute.
> In Section 4.1.1 (Algorithm), the RFC states "This Header Parameter MUST
> be present .." and in Section 5.1 (Message Signature), "..(algorithm)
> Header Parameter MUST be present in the JOSE Header..". This implies
> that "alg" is part of the "protected" section of the JWS.
> However, there is no guidance on how the "protected" attribute must be
> encoded when both, "alg" and "x5c" are present in the JWS. It seems
> logical that it would be encoded as a sub-JSON object; but there is
> neither any guidance nor an example of what is canonical here.

The contents of the "protected" attribute is identical to the header for compact serialization.  That is, a base64url encoded JSON object holding JOSE header data.

> Second, if one creates a sub-JSON for "protected" in a "Flattened" JWS,
> should the "protected" attribute remain in text form or should it be
> Base64Url encoded before being signed?

Flattened JWS is just about taking the JWS compact elements apart.  You can create a valid Flattened JWS from a Compact JWS without any computations.

> 3) Appendix B shows an example of an X.509 Certificate Chain using
> Base64-encoded strings to represent certificates. While this will work
> with most code, is there any rationale for departing from the PKI
> industry practice of using PEM encoded certificates for textual
> representations (considering the JWS JSON Serialization is not concerned
> with space limitations)? This advice is mandated in Section 4.1.5 for
> "x5u", referencing Section 6.1 of RFC 4945, but not so for "x5c".

The rationale for the "x5c" syntax is that it is "closer" to PEM than base64url :)

If you are looking for a more JSON-oriented signature solution you might take a look at:


> Thank you.
> Arshad Noor
> StrongKey
> _______________________________________________
> jose mailing list