invalidKeySpecException error "not in PKCS8 format"

Issue #97 resolved
limsonk created an issue

Encrypted JWT token parsing I am trying to use nimbus-jose-jwt-2.25.jar. but here I got blocked on loading the private key ,which is reading as external file (.pem/.key format) . Code Snippet: byte [] encoded = Base64.decodeBase64(pemBytes); PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encoded); KeyFactory kf = KeyFactory.getInstance("RSA"); PrivateKey pk = kf.generatePrivate(keySpec); <- error loading private key has been failed on invalidKeySpecException error not in PKCS8 format.

I have tried to downgrading the code nimbus-jose-jwt--2.15.1 as mentioned here "http://social.msdn.microsoft.com/Forums/en-US/951f090d-6013-4d76-88a9-67e13fabaa83/padding-error-while-decrypt-jwt-sso-token-with-josejwt?forum=xboxoneappswithhtml5"

but unfortunately no luck could you help me on this issue.

Thanks,in advance.

Comments (4)

  1. limsonk reporter

    Hi Vladimir, Thanks for your reply. Yes your assumption is correct this was the issue and luckily I could identify and resolved resolved the issue.

    Best Limson km

  2. Log in to comment