Enabling message signing
Steps to turn on message signing so subscribers can establish which service actually published a message. See Signing messages for the flow, full property reference, metrics and failure cases.
-
Get a private key and matching certificate for your service, with a CN equal to
spring.application.name(whichjeap.messaging.kafka.serviceName— the publisher name in the message identity — defaults to, unless overridden separately).- Production: obtained the same way as your service's other secrets, through your platform's PKI / secrets management — this is outside jEAP Messaging's scope, which only consumes the PEM values via configuration.
- Local/dev/test: a self-signed certificate is enough. Include
-nodesso the key is written unencrypted (BEGIN PRIVATE KEY) —signature-keyonly accepts an unencrypted PKCS#8 key, and an encrypted one (BEGIN ENCRYPTED PRIVATE KEY, which is what you get without-nodes) fails to even base64-decode:openssl req -x509 -nodes -newkey rsa:2048 -keyout service-key.pem -out service-cert.pem -days 365 -subj "/CN=my-service"
-
Configure the publisher side with that key and certificate (
jeap.messaging.authentication.publisher.*):jeap:messaging:authentication:publisher:signature-key: |-----BEGIN PRIVATE KEY-----...-----END PRIVATE KEY-----signature-certificate: |-----BEGIN CERTIFICATE-----...-----END CERTIFICATE-----At startup jEAP checks that the key matches the certificate and that the certificate's CN matches
spring.application.name— the service fails to start otherwise. That check is against the static Spring property, not the message'spublisher.servicefield itself; the two only coincide becausejeap.messaging.kafka.serviceNamedefaults tospring.application.nameby convention. The per-message publisher identity is what subscribers actually verify against, on each received message. -
Distribute the certificate (chain) to every subscriber that needs to verify it (
jeap.messaging.authentication.subscriber.certificate-chains). This is keyed by publisher service name, then by an arbitrary chain name of your choosing (so a publisher can have more than one chain active at once, e.g. during rotation — see step 6), and each named chain is a list of[leaf, optional intermediates, root]:jeap:messaging:authentication:subscriber:certificate-chains:my-publishing-service:chain-2026:- |-----BEGIN CERTIFICATE-----... leaf ...-----END CERTIFICATE------ |-----BEGIN CERTIFICATE-----... root ...-----END CERTIFICATE----- -
Roll out without breaking existing consumers, in this order:
- Deploy subscribers first, leaving
require-signatureat its default (false). With itfalse, the subscriber only checks that thejeap-sign/jeap-sign-key/jeap-certheaders are consistently present or absent — it does not yet cryptographically verify the signature of a signed message, so unsigned traffic from not-yet-updated publishers keeps flowing and signed traffic isn't actually checked either. - Deploy the publisher with
signature-key/signature-certificateconfigured. Messages now carry signature headers, but withrequire-signaturestillfalseon the subscribers, these signatures are not yet verified — this step only gets the headers flowing so step 3 can enable verification without an outage. - Once every relevant publisher signs its messages, set
require-signature: trueon the subscribers to actually enable signature verification and enforce it — optionally whitelisting message types that intentionally stay unsigned viaaccept-unsigned-messagetype-whitelist. Do this deliberately, in a step where you can watch the metrics below, since it's the point at which verification (and thus any configuration/certificate problem) first takes effect.
- Deploy subscribers first, leaving
-
Watch the rollout with the signing metrics:
jeap_messaging_signature_validation_outcome(OK/NOK, per app and message type) to confirm verification is succeeding — note this metric is only meaningful oncerequire-signature: trueis set, since before that no value signature is actually verified — andjeap_messaging_signature_certificate_days_remainingso an expiring certificate doesn't surprise you. -
Before a certificate expires, request/generate its replacement for the same CN, then rotate without a gap by adding rather than replacing: add the new certificate chain to the subscribers under a new chain name next to the existing one (e.g.
chain-2027alongsidechain-2026) and deploy — subscribers now accept either certificate — then roll the publisher'ssignature-key/signature-certificateto the new one. Only remove the old chain name from the subscribers once you're sure no message signed with the old key can still turn up — i.e. after both the normal consumer-lag/processing window and the longest period you could still replay messages from have passed, not just after a successful verification with the new key. Subscribers resolve the signing certificate by serial number (SubscriberCertificatesContainer.getCertificateWithSerialNumber()), so once the old chain is removed, any message that is still signed with the old certificate — from a replay or a straggling consumer — can no longer be verified; withrequire-signature: truethat fails the message to the Error Handling Service instead of just missing the OK-metric. Plan the rotation cadence with enough lead time before certificate expiry to cover this.