You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JWTAuth jwtAuth = JWTAuth.create(vertx, new JWTAuthOptions() .addPubSecKey(new PubSecKeyOptions() .setAlgorithm("ES256") .setBuffer( "-----BEGIN PUBLIC KEY-----\n" + "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEraVJ8CpkrwTPRCPluUDdwC6b8+m4\n" + "dEjwl8s+Sn0GULko+H95fsTREQ1A2soCFHS4wV3/23Nebq9omY3KuK9DKw==\n" + "-----END PUBLIC KEY-----")));
The JWTAuth creation is OK.
However when I try to use a JsonObject to build PubSecKeyOptions, like this:
JWTAuth jwtAuth = JWTAuth.create(vertx, new JWTAuthOptions() .addPubSecKey(new PubSecKeyOptions(new JsonObject() .put("algorithm","ES256") .put("buffer", "-----BEGIN PUBLIC KEY-----\n" + "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEraVJ8CpkrwTPRCPluUDdwC6b8+m4\n" + "dEjwl8s+Sn0GULko+H95fsTREQ1A2soCFHS4wV3/23Nebq9omY3KuK9DKw==\n" + "-----END PUBLIC KEY-----"))));
This exception is raised
Caused by: java.lang.IllegalArgumentException: Illegal base64 character 2d
at java.util.Base64$Decoder.decode0(Base64.java:743) ~[?:?]
at java.util.Base64$Decoder.decode(Base64.java:535) ~[?:?]
at java.util.Base64$Decoder.decode(Base64.java:558) ~[?:?]
at io.vertx.ext.auth.PubSecKeyOptionsConverter.fromJson(PubSecKeyOptionsConverter.java:30) ~[vertx-auth-common-4.3.4.jar:4.3.4]
at io.vertx.ext.auth.PubSecKeyOptions.(PubSecKeyOptions.java:52) ~[vertx-auth-common-4.3.4.jar:4.3.4]
I do not understand why the key format should be different in both cases, so why same value cannot be used :/
I guess the multiline format of the Key might not be adapted to Json...
Then, What is format of the pub key "buffer" to provide in JsonObject to make it works?
Edit:
I've called the PubSecKeyOptions.toJson() from instance created with POJO setters:
The buffer format is in fact the Base64URL encoding of "buffer" provided using POJO method:
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEraVJ8CpkrwTPRCPluUDdwC6b8+m4
dEjwl8s+Sn0GULko+H95fsTREQ1A2soCFHS4wV3/23Nebq9omY3KuK9DKw==
-----END PUBLIC KEY-----
Version
vertx 4.3.4
Context
When I use the code from this Doc page/
JWTAuth jwtAuth = JWTAuth.create(vertx, new JWTAuthOptions() .addPubSecKey(new PubSecKeyOptions() .setAlgorithm("ES256") .setBuffer( "-----BEGIN PUBLIC KEY-----\n" + "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEraVJ8CpkrwTPRCPluUDdwC6b8+m4\n" + "dEjwl8s+Sn0GULko+H95fsTREQ1A2soCFHS4wV3/23Nebq9omY3KuK9DKw==\n" + "-----END PUBLIC KEY-----")));
The JWTAuth creation is OK.
However when I try to use a JsonObject to build PubSecKeyOptions, like this:
JWTAuth jwtAuth = JWTAuth.create(vertx, new JWTAuthOptions() .addPubSecKey(new PubSecKeyOptions(new JsonObject() .put("algorithm","ES256") .put("buffer", "-----BEGIN PUBLIC KEY-----\n" + "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEraVJ8CpkrwTPRCPluUDdwC6b8+m4\n" + "dEjwl8s+Sn0GULko+H95fsTREQ1A2soCFHS4wV3/23Nebq9omY3KuK9DKw==\n" + "-----END PUBLIC KEY-----"))));
This exception is raised
Extra
Root cause seems to be related to PubSecKeyOptionsConverter - line 30
obj.setBuffer(io.vertx.core.buffer.Buffer.buffer(BASE64_DECODER.decode((String)member.getValue())));
As a BASE64_DECODER is used to set the buffer when JsonObject is used,
But in PubSecKeyOptions buffer is set without Base64 decoding
this.buffer = Buffer.buffer(buffer, "UTF-8");
The text was updated successfully, but these errors were encountered: