Skip to content

Document the JSON form of PubSecKeyOptions buffer - #761

Merged
tsegismont merged 1 commit into
eclipse-vertx:masterfrom
SiteNetSoft:issue-596-pubseckey-json-docs
Aug 25, 2026
Merged

Document the JSON form of PubSecKeyOptions buffer#761
tsegismont merged 1 commit into
eclipse-vertx:masterfrom
SiteNetSoft:issue-596-pubseckey-json-docs

Conversation

@jnbdz

@jnbdz jnbdz commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Fixes #596

PubSecKeyOptions.buffer is a Buffer, so its JSON representation is the base64 encoding of the key bytes (standard Vert.x Buffer ↔ JSON mapping via the generated converter), not the PEM text. That is consistent with the rest of Vert.x, but it was undocumented, and the docs' PEM examples lead users to paste the PEM into a JSON config and hit IllegalArgumentException: Illegal base64 character — exactly the report in #596 (the reporter eventually discovered the base64 form on their own).

This PR does not change behaviour; it documents it and pins it with tests:

  • PubSecKeyOptions javadoc (class + both setBuffer overloads) explains the JSON representation and how to obtain it: new PubSecKeyOptions().setBuffer(pem).toJson().
  • vertx-auth-jwt docs: new "Configuring keys from JSON" subsection under "Loading Keys", with AuthJWTExamples#example19.
  • PubSecKeyOptionsTest (common): setter → toJson() → JSON-constructor round trip, base64 PEM loads into a usable JWK, raw PEM in JSON is rejected.
  • JWTAuthFromJsonTest (jwt): a JWTAuth built from JSON config verifies a token signed by the setter-configured twin, and the resulting PubSecKeyOptions are identical.

I deliberately did not add a "starts with -----BEGIN" heuristic to the JSON constructor: ambiguous decoding of key material in a security config type seems worse than a documented, uniform rule.

@tsegismont tsegismont left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

When PubSecKeyOptions are created from JSON the buffer field is a Buffer,
which is represented in JSON as the base64 encoding of the key bytes rather
than the PEM text. Nothing documented this, so pasting a PEM into JSON fails
with "Illegal base64 character".

- PubSecKeyOptions javadoc explains the JSON representation and how to obtain
  it (new PubSecKeyOptions().setBuffer(pem).toJson())
- vertx-auth-jwt docs gain a "Configuring keys from JSON" section with an
  example (AuthJWTExamples#example19)
- PubSecKeyOptionsTest covers the JSON round trip and JWTAuthFromJsonTest
  proves a JSON configured provider verifies tokens signed by a setter
  configured one

Fixes eclipse-vertx#596
@tsegismont
tsegismont force-pushed the issue-596-pubseckey-json-docs branch from f8d0f00 to f98bbd4 Compare August 25, 2026 15:29
@tsegismont
tsegismont merged commit 15ceb8e into eclipse-vertx:master Aug 25, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[JWT Auth provider] PubSecKeyOptions creation fails when using JsonObject

2 participants