Questions tagged [jose4j]

The jose4j library is an open source (Apache 2.0) implementation of JWT and the JOSE specification suite. It is written in Java and relies solely on the JCA APIs for cryptography.

JSON Web Token (JWT) is a compact, URL-safe means of representing claims to be transferred between two parties. JWT is the identity token format in OpenID Connect and it is also widely used in OAuth 2.0 and many other contexts that require compact message security.

JOSE is short for Javascript Object Signing and Encryption, which is the IETF Working Group that developed the JSON Web Signature (JWS), JSON Web Encryption (JWE) and JSON Web Key (JWK) specifications. JWS and JWE use JSON and base64url encoding to secure messages in a (relatively) simple, compact and web safe format while JWK defines a JSON representation of cryptographic keys. The actual algorithms for JWS, JWE and JWK are defined in JSON Web Algorithms (JWA). The library supports the JWS/JWE compact serializations with the complete suite of JOSE algorithms.

The homepage for jose4j is at: https://bitbucket.org/b_c/jose4j/wiki/Home

84 questions
2
votes
1 answer

Unexpected "InvalidJwtSignatureException: JWT rejected due to invalid signature"

I have a JWT that looks like this (I had to hide some…
2
votes
1 answer

Trusting SSL certificates: how does Commons HTTP client trust more than standard Java?

To validate a JWT, I'm using jose4j to get certificate from an url, in this case, from google: HttpsJwks httpsJkws = new HttpsJwks("https://www.googleapis.com/oauth2/v3/certs"); HttpsJwksVerificationKeyResolver httpsJwksKeyResolver = new…
Steven De Groote
  • 2,187
  • 5
  • 32
  • 52
2
votes
2 answers

Jose4j validate signature alg RS256 against encryption algorithm

The JWT is signed with RS256, and I am using jose4j to verify JWT signature. In one of user environment which I do not have access, it generates this unexpected exception: org.jose4j.lang.InvalidAlgorithmException: RS256 is an unknown, …
Chunlong
  • 616
  • 5
  • 9
2
votes
1 answer

Json Web Token - jose4j - SyntaxError: Unexpected token e in JSON at position 0

I have a controller which tries to get a token. I got this error in postman when I execute it in the view PRETTY Unexpected 'e' But if I go to the view RAW I can see the token like…
Maximus Decimus
  • 4,901
  • 22
  • 67
  • 95
2
votes
1 answer

Accessing JWT nested claims with jose4j

I am having trouble accessing nested claims from a JWT using jose4j. I have a JWT whose claim set looks like this: { "iss": "awesome.issuer", "iat": 1300819370, "exp": 1300819380, "clm": "string claim", "sub": "batman", …
Michael Davis
  • 2,350
  • 2
  • 21
  • 29
2
votes
2 answers

Error Decrypting JWE

Kind of new to the JWE Decryption thing. I have a server that performs the JWE and sent it to client based on a key that is shared between server and client. I am using a Jose4j for decrypting and am getting this…
Aravind R
  • 716
  • 1
  • 10
  • 36
2
votes
1 answer

JWT becomes invalid after restarting the server

I am generating a public/private key pair which i will use for digital signature of a JWT with jose4j. Its working fine creating and validating the token as well. But once i restart the server, then the previously issued tokens become invalid. I…
Shubham Jain
  • 56
  • 1
  • 5
2
votes
2 answers

Verifying JWT using jsonwebtoken in node.js with a token generated by jose4j fails

I'm trying to verify a json web token generated by jose4j using jsonwebtoken in node.js and I see the following error: [Error: PEM_read_bio_PUBKEY failed] The jose4j code is basically lifted straight from the example: RsaJsonWebKey key =…
Nim
  • 33,299
  • 2
  • 62
  • 101
2
votes
2 answers

how to populate a jsonwebkey from a generated ecdsa key

I try to generate a public/private key pair which i will use for digital signature of a JWT with jose4j. I use Elliptic Curve Digital Signature Algorithm My problem is that i don't know how to get the parameters representing the edcsa key…
David Michael Gang
  • 7,107
  • 8
  • 53
  • 98
2
votes
2 answers

Parser exception in JWT when encryption and signing is enabled

I'm new to JWT, learning through standalone code to understand JWT API's. Below code sign and encrypt JWT token from sender's end and it get validated at receiver's end. Library: JOSE 0.4.1 package com.one00bytes.jwt; public class…
Ashok
  • 461
  • 2
  • 5
  • 23
1
vote
2 answers

How to use RSA as kty jwk parameter (using jose4j)

I am using jose4j to encrypt a String with JWE, following this documentation https://bitbucket.org/b_c/jose4j/wiki/JWE%20Examples In the example, they used {\"kty\":\"oct\",\"k\":\"Fdh9u8rINxfivbrianbbVT1u232VQBZYKx1HGAGPt2I\"} It works well, but…
Sushi
  • 646
  • 1
  • 13
  • 31
1
vote
0 answers

iOS JWE AES GCM 256

I am trying to implement JWE token in Swift using JOSESwift (modified to support AES-GCM 256) and CryptoSwift(need to support iOS 11+). I am able to encrypt and decrypt using public/private key pair. But when the same JWE token passed on to Java…
1
vote
1 answer

I have Modulus and Exponent how to generate JWE for some payload using JavaScript

We have a requirement where we will get modulus from service call to be used for encrypting (JWE) some data at client side Example of modulus, and exponent (cannot be changed formats) { "modulus":…
Kiran
  • 1,145
  • 1
  • 8
  • 22
1
vote
1 answer

How to add OAEPParameterSpec to a JWE object?

I need to add an OAEPParameterSpec as a AlgorithmParameterSpec to a JWE (Json Web Encryption) object. How can I do that? I'm using a client - server application. server is encrypting in RSA-OAEP-256 encryption algorithm, client is failing at…
RBis
  • 33
  • 5
1
vote
1 answer

ECDH + JWE encryption/decryption using jose4j

I am trying to implement ECDH encryption/decryption along with JWE in Android (Java). I have found the jose4j and Nimbus JOSE libraries that aim to do everything I need but appears that it's more challenging than I thought. If anybody is familiar…
Michael Kessler
  • 14,245
  • 13
  • 50
  • 64