Class BusEnvelopeCanonical
- Namespace
- Stratara.Abstractions.Messaging
- Assembly
- Stratara.Abstractions.dll
Canonical payload projection helpers used by both publishers (when signing) and consumers (when verifying) so the two sides hash identical bytes. The projection covers every field of the message except the signature itself.
public static class BusEnvelopeCanonical
- Inheritance
-
BusEnvelopeCanonical
- Inherited Members
Remarks
Two properties make this projection safe, and both are load-bearing.
Every field is length-prefixed. Joining fields with a separator they are allowed to contain would let content be shifted across a field boundary without changing the projection — so an attacker could alter which command type is dispatched while the signature still verified, defeating the very guard the type name is signed for.
The projection is built from field values, never by re-serializing. The payloads survive the envelope's own deserialization as strings, and every other field is a scalar with a canonical text form, so a message that has been on the wire projects to exactly what its publisher signed. Re-serializing would make the projection depend on property order, escaping and culture, and the resulting failures would be intermittent rather than immediate — the worst shape a signature check can have.
Changing this projection invalidates signatures produced by an older publisher. Fleets move through permissive mode: publishers first, consumers after, then strict again.
Methods
Of(CommandEnvelope)
Canonical projection of a CommandEnvelope — covers the envelope id, the command type, the session context, the heavy-lane flag, a digest of the command payload and, where the command named its data owner, that owner's tenant and user.
public static string Of(CommandEnvelope envelope)
Parameters
envelopeCommandEnvelopeThe envelope to project.
Returns
- string
The canonical string to sign or verify.
Remarks
The owner is appended only when the envelope carries one, so an envelope that names none projects to what it projected to before an envelope could name one, and hosts on either side of that release verify each other's signatures for it. Because every field is length-prefixed, an envelope with an owner and the same envelope without one never project to the same string. Both owner fields are appended as soon as either is set, so neither can be added to a signed envelope on its own.
Exceptions
- ArgumentNullException
envelopeisnull.
Of(EventBundle)
Canonical projection of an EventBundle — covers the session context and a digest over every field of every event it carries.
public static string Of(EventBundle bundle)
Parameters
bundleEventBundleThe bundle to project.
Returns
- string
The canonical string to sign or verify.
Exceptions
- ArgumentNullException
bundleisnull.