Standards
Signing a vCon with JWS and verifying it, step by step
How draft-ietf-vcon-vcon-core-05 shapes a signed vCon: general JWS, x5c or x5u, RS256, a uuid header, plus a short Python sketch.
IETF working group draft Last updated 18 November 2026
What the draft asks for
The core draft, draft-ietf-vcon-vcon-core-05, states that a signed vCon uses JSON Web Signature in the General JWS JSON Serialization, with the unsigned vCon JSON (or its gzipped form) as the base64url payload 1. The signature objects must follow RFC 7515, and the unprotected header must include x5c or x5u so a verifier can find the certificate chain 12. The alg value must be present, should sit in the protected header so it is integrity protected, must not be none, and should be RS256 for interoperability 1. A uuid header SHOULD repeat the vCon's uuid so a system can route the document without verifying it, and the verifier SHOULD compare the two after verifying 1.
{
"payload": "<base64url of the unsigned vCon JSON>",
"signatures": [
{
"protected": "<base64url of {\"alg\":\"RS256\"}>",
"header": {
"x5u": "https://certs.example.com/vcon-signer.pem",
"uuid": "0198e6a4-3c1b-8a52-9f0e-5d2c7b1a4e60"
},
"signature": "<base64url signature>"
}
]
}Step by step
- 1. Finish the unsigned vCon. The draft says a domain SHOULD sign before a vCon leaves it, and that updated_at in a signed form records the last signing time, so set it first 1.
- 2. Make sure every external file is already referenced with url and content_hash. The signature covers the hashes, which is how it protects files stored elsewhere 1.
- 3. Serialize the JSON and use it as the payload; compress it with gzip first if size matters. Receivers SHOULD be able to accept gzip, and senders do not have to use it 1.
- 4. Sign with an RSA key using RS256, putting alg in the protected header and x5c or x5u plus uuid in the unprotected header 1.
- 5. Publish the certificate chain. RFC 7515 requires an x5u address to be fetched over TLS and the first certificate to hold the signing key 2.
- 6. On receipt, identify the form (a payload plus signatures means signed) 1, validate the certificate chain, verify the signature, then compare the header uuid with the inner vCon uuid 12.
import base64, json
from jwcrypto import jwk, jws
from jwcrypto.common import json_encode
def b64u_decode(s: str) -> bytes:
return base64.urlsafe_b64decode(s + "=" * (-len(s) % 4))
def sign_vcon(vcon: dict, key: jwk.JWK, x5u: str) -> dict:
"""Return a general-form JWS (payload + signatures[])."""
s = jws.JWS(json.dumps(vcon, separators=(",", ":")).encode())
s.add_signature(
key,
protected=json_encode({"alg": "RS256"}), # integrity-protected
header=json_encode({"x5u": x5u, "uuid": vcon["uuid"]}), # unprotected
)
flat = json.loads(s.serialize(compact=False)) # library emits flattened form
return {"payload": flat.pop("payload"), "signatures": [flat]}
def verify_vcon(signed: dict, key: jwk.JWK) -> dict:
"""Check ONLY the first signature, against a key you already trust."""
sig = signed["signatures"][0]
hdr = {**json.loads(b64u_decode(sig["protected"])), **sig["header"]}
if hdr.get("alg") in (None, "none"):
raise ValueError("alg missing or none")
if "x5c" not in hdr and "x5u" not in hdr:
raise ValueError("x5c or x5u required")
check = jws.JWS()
check.deserialize(json.dumps(signed))
check.verify(key, alg="RS256") # raises on a bad signature
payload = bytes(check.payload)
if payload[:2] == b"\x1f\x8b": # gzip magic: decompress first
import gzip; payload = gzip.decompress(payload)
vcon = json.loads(payload)
if "uuid" in hdr and hdr["uuid"] != vcon["uuid"]:
raise ValueError("header uuid does not match payload")
return vcon
What the sketch leaves out: it verifies against a key you already hold, so it does not parse or validate the x5c or x5u certificate chain, check certificate expiry or revocation, or decide whether the signer is trusted; RFC 7515 makes chain validation the recipient's job 2. It checks only the first signature in the list. It builds the general form by hand from the library's flattened output, because the library emits the flattened syntax for a single signature; check this against your library version. The code is not an official reference.
Long-lived records
Signing certificates expire, often within a few years, while compliance records may be kept for ten years or more. The draft describes one approach: before a certificate expires, verify the existing signed object and then sign it as the payload of a new JWS, repeating for the life of the archive, so only the outermost signature must be checked later 1. It adds that other approaches may exist 1.
Common mistakes this order prevents
- Editing a signed vCon in place. The draft says a signed or encrypted vCon cannot be modified without invalidating it, so changes require a new instance version that refers to the old one through amended_from 1.
- Trusting an unsigned header. The uuid header is a convenience; compare it after verification 1.
- Accepting alg none. The draft forbids it, and its appendix says older documents using it are migrated by signing again 1.