A support ticket that recurs across every offline-first licensing system reads roughly the same: "The license worked on the customer's old build and fails on the new one. We didn't reissue it. The bytes on disk are identical." The key was not revoked, the clock is fine, the signature algorithm did not change. And yet Verify returns false.
Almost always, the cause is the same category error: somewhere, someone signed an object and expected to verify an object. Signatures do not work on objects. They work on bytes.
The real question
A Keyright license is a set of claims — product, tier, seats, expiry — and a signature that proves those claims came from you. The temptation is to think of the signature as covering "the license." It does not. It covers one specific sequence of bytes: whatever the issuer serialized the claims to at signing time. Verification asks a single question — "is this signature valid for these exact bytes under this public key?" — and the cryptography answers it honestly. If the bytes the verifier hands it differ from the bytes the signer signed by even one byte, the honest answer is false.
So the question that decides whether your licensing works is not "which algorithm?" It is: do the issuer and the SDK agree, byte for byte, on what was signed? Get that wrong and authentic licenses fail; the algorithm is blameless.
How the bytes drift
Here is the shape of the mistake. The issuer builds a claims object and signs its JSON:
var claims = new LicenseClaims { LicenseId = "KR-7F3A-9C21", Product = "acme-suite", Tier = "pro", Seats = 5, IssuedAt = DateTimeOffset.Parse("2026-11-24T10:00:00Z"), ExpiresAt = DateTimeOffset.Parse("2027-11-24T10:00:00Z"), }; byte[] signed = JsonSerializer.SerializeToUtf8Bytes(claims); byte[] sig = signer.Sign(signed); // over `signed` The SDK, written months later by someone else, reconstructs the claims from a transport DTO and re-serializes before verifying:
var claims = MapFromDto(dto); // same logical values byte[] toVerify = JsonSerializer.SerializeToUtf8Bytes(claims); bool ok = signer.Verify(toVerify, sig); // over `toVerify` Both call JsonSerializer. Both produce "the claims as JSON." And ok can still be false, because signed and toVerify are not guaranteed to be the same bytes. Four independent things can differ.
Property order. System.Text.Json emits properties in metadata/reflection order. Change the declaration order of two fields, add a [JsonPropertyOrder], or map through a Dictionary<string,object> whose enumeration order you do not control, and {"tier":"pro","seats":5} becomes {"seats":5,"tier":"pro"}. Same meaning, different bytes.
Whitespace. One side constructs JsonSerializerOptions { WriteIndented = true } for readable logs and shares the options object with the signer. Now the signed bytes carry newlines and two-space indents the verifier never reproduces.
String escaping. The default encoder escapes non-ASCII. A company name of "Café Ltée" is signed as Café Ltée; a verifier configured with UnsafeRelaxedJsonEscaping writes the literal UTF-8 Café Ltée. Byte-for-byte different, character-for-character identical.
Numbers and culture. This is the cruel one. Seats is fine as an integer, but the moment any claim is a decimal — a metered allowance of 1.5 units — the formatter's culture decides whether it writes 1.5 or 1,5. A verifier running on a machine whose current culture is de-DE or fr-FR, using a code path that touches CultureInfo.CurrentCulture, can turn an authentic 1.5 into 1,5. The signature was never valid for 1,5.
Design one: verify the bytes you received
The robust fix is to stop treating the signed payload as "an object you can rebuild" and start treating it as an opaque byte string you were handed. The license on the wire is a small envelope: the canonical payload and a detached signature over exactly those bytes.
public sealed class LicenseEnvelope { // The exact UTF-8 bytes that were signed, base64url-encoded. Opaque in transit. public required string Payload { get; init; } public required string Signature { get; init; } // over the decoded Payload bytes public required string KeyId { get; init; } // which public key verifies it } The SDK verifies first, over the received bytes, and only parses the bytes the signature has already blessed:
public LicenseClaims Open(LicenseEnvelope env) { byte[] payload = Base64Url.Decode(env.Payload); byte[] sig = Base64Url.Decode(env.Signature); var key = _keys.Resolve(env.KeyId) ?? throw new LicenseException("unknown signing key"); if (!key.Verify(payload, sig)) // over the ORIGINAL bytes throw new LicenseException("signature invalid"); // Only now do we parse — the bytes are already trusted. return JsonSerializer.Deserialize<LicenseClaims>(payload) ?? throw new LicenseException("empty payload"); } Two properties fall out of this. The verifier never regenerates the payload, so none of the four drifts can occur — property order, whitespace, escaping and number format are frozen in the transported bytes. And the JSON parser runs after the signature check, not before, so your parser is never exposed to unverified input. This is the model Keyright SDKs use: verify the payload as it arrived, then parse.
The one rule you must hold on the issuing side is that the bytes you signed are the bytes you transport. Sign, then base64 the signed buffer — never re-serialize the claims a second time to build the envelope.
Design two: canonicalize on both sides
Sometimes you cannot transport the raw bytes — you are embedding claims in a JWT whose own library re-encodes them, or two independent implementations must interoperate without agreeing on a buffer. Then both sides must compute the same bytes deterministically. That is JSON Canonicalization (RFC 8785, "JCS"): members sorted by UTF-16 code unit, no insignificant whitespace, minimal string escaping, numbers in one defined shortest form, UTF-8 output.
The parts that bite with System.Text.Json are ordering and formatting, and both are fixable:
static byte[] Canonicalize(LicenseClaims c) { // Sorted keys, invariant culture, no indentation, strict number handling. var ordered = new SortedDictionary<string, object?>(StringComparer.Ordinal) { ["expiresAt"] = c.ExpiresAt.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"), ["issuedAt"] = c.IssuedAt.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"), ["licenseId"] = c.LicenseId, ["product"] = c.Product, ["seats"] = c.Seats, ["tier"] = c.Tier, }; var opts = new JsonSerializerOptions { WriteIndented = false, Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, // same escaping both sides }; return JsonSerializer.SerializeToUtf8Bytes(ordered, opts); } Dates are forced to a fixed UTC string instead of being left to the serializer; numbers stay integers; culture is removed from the equation because the output is a plain integer with no decimal separator. If a claim genuinely needs a fractional value, format it yourself with CultureInfo.InvariantCulture and a fixed "R"/shortest round-trip form so 1.5 is never 1,5. The issuer signs Canonicalize(claims); the SDK computes Canonicalize(claims) and verifies the signature against it. Identical inputs, identical bytes, matching signature.
When it still breaks
Canonicalization has sharp edges that Design one simply does not have. Floating-point numbers do not canonicalize cleanly across languages — 0.1 has no exact binary form, and two runtimes can disagree on its shortest decimal; keep money and allowances as integers (cents, whole units) and you sidestep it. Unicode normalization is a second trap: "é" as one code point and "e" plus a combining accent are different bytes but render identically, so normalize strings (NFC) before you canonicalize or compare. And any field your canonicalizer forgets to include is a field the signature does not protect — if you add a claim to the DTO but not to Canonicalize, an attacker can set it freely. Design one has none of these failure modes because it never regenerates anything, which is exactly why it is the default worth reaching for first.
Takeaway
A signature proves that a byte string came from the holder of a private key. It proves nothing about an object, because the object does not exist at the cryptographic layer — only the bytes it happened to serialize to. Treat the signed payload as those bytes: transport them intact, verify them verbatim, and parse only once the signature has vouched for them. Reach for canonicalization only when you truly cannot carry the originals, and when you do, pin ordering, escaping, culture and number form on both sides. Do that and the recurring ticket disappears, because the verifier is finally asking the cryptography the same question the signer answered.
Keyright is a self-hosted .NET licensing system — an issuing service plus SDK — with a free Community Edition. The verification model described here is built in; integration details are in the Keyright docs.