Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JWT Authentication is not working due to invalid certificate selection from client-truststore #6833

Open
TomasTokaMrazek opened this issue Nov 15, 2019 · 10 comments

Comments

@TomasTokaMrazek
Copy link

We set up custom hostname with proper certificate generated from trusted CA authority.

I can sucessfully generate JWT token from API Gateway. It's header property "x5t" is SHA-1 fingerprint.

In system directory /repository/resources/security there are two JKS.

  • wso2carbon.jks – with private/public key pair alias named wso2carbon
  • client-truststore.jks – with certificate alias named wso2carbon

both wso2carbon entries have the same fingerprint as specified in JWT header property. Yet the API call response is Invalid JWT token. Signature verification failed.

Is there any configuration we could've missed or is it a bug?

@tmkasun
Copy link
Contributor

tmkasun commented Nov 15, 2019

What is the API Manager version that you are using ?

@TomasTokaMrazek
Copy link
Author

@tmkasun 3.0.0. AFAIK using JWT token instead of Oauth2 is a new feature introduced. I'm talking about "Token Type"

image

@TomasTokaMrazek
Copy link
Author

In our environment we switched back to OAUTH token type, which works as expected. JWT Token Type is the one we had issues with.

@tmkasun tmkasun added the 3.0.0 DEPRECATED Label; Use Affected/3.0.0 instead label Nov 16, 2019
@imchivaa
Copy link

imchivaa commented Dec 5, 2019

Hi,

we also facing the same issue, using v3.1.0-m2 release.
We getting below error after generate the JWT token from application and invoke the api

<ams:fault xmlns:ams="http://wso2.org/apimanager/security">
    <ams:code>900901</ams:code>
    <ams:message>Invalid Credentials</ams:message>
    <ams:description>Invalid JWT token. Signature verification failed.. Make sure you have provided the correct security credentials</ams:description>
</ams:fault>

Subsequent invoke print this log:

TID: [-1234] [] [2019-12-05 15:03:05,267] ERROR {org.wso2.carbon.apimgt.gateway.handlers.security.jwt.JWTValidator} - Invalid JWT token. XXXXXfVgQW9bdmg
TID: [-1234] [] [2019-12-05 15:03:05,270]  WARN {org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler} - API authentication failure due to Invalid Credentials

As OP mentioned, OAuth works fine. Just having issue with JWT.

Any update on this issue?
Thanks.

@imchivaa
Copy link

imchivaa commented Dec 5, 2019

@TomasTokaMrazek
Copy link
Author

Looks like the issue is due to specific alias gateway_certificate_alias – that's what I actually found in source code. I'll test it, thank you @imchivaa for linking the updated documentation

@TomasTokaMrazek
Copy link
Author

Documentation

@rmsamitha rmsamitha added Affected/3.0.0 and removed 3.0.0 DEPRECATED Label; Use Affected/3.0.0 instead labels Apr 2, 2020
@tmkasun tmkasun reopened this Apr 9, 2020
@ViktorHSN
Copy link

Hello,
I am still having a similar problem to this.
I am using a third party IDP as the keymanager (keycloak based IDP)
I´ve imported the public certificate to the truststore under the gateway_certificate_alias.

However in the third party keymanager docs, under the "extending key validation handler" section states that token validation is done in getTokenMetaData() method, which is never called in my setup. Am I missing any configuration step? I need this method to get called so I my IDP can validate the token.

@PrabakaranTS
Copy link

I'm also facing the same issue. We are using APIm 3.1.0 and IS-KM 5.10.0. We have imported the certificate of IS-KM to APIm with gateway_certificate_alias and restarted but still, the issue is not resolved.

@ViktorHSN
Copy link

ViktorHSN commented Sep 29, 2020

Hello, I got it working, In my case, I had to import the public certificate of the Realm in RH-SSO which signed the jwt token under an alias corresponding to its KID.

Good news is that WSO2 APIM 3.2.0, the newest version at the time of this writing, suports adding keymanager via its admin interface, which makes the process easier, but I still had to import the certificate as I stated above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants