Closed lucaslacerdacl closed 4 years ago
@lucaslacerdacl thanks for opening this issue and confirming that the App works for you on localhost
. Without access to the Dockerfile
and more of your code we do not have enough to help debug this.
Can you please confirm that jwtConfig.publicKey
is defined?
@nelsonic I guess I've figured out whats happening.
I was printing my private and public key after read from a file and it was all fine, however, when I printed the key inside hapi-auth-jwt2 module i discovery that only my private key was present.
In the props key I add public and private key (perviously was only private key):
server.auth.strategy('jwt', 'jwt', {
key: [jwtConfig.privateKey, jwtConfig.publicKey],
...
And it's work!
My conclusion was that the module was trying to decode my token with the private key.
I also remove the code:
Jwt.verify(request.headers.authorization, jwtConfig.publicKey, {
issuer: jwtConfig.issuer,
});
Because the module has already verify the integrity of the token.
Is my conclusion correct good sir?
@lucaslacerdacl yeah, that makes sense. Provided your JS code is reading the keys correctly from the Docker environment and you can successfully make an API request to the App running inside Docker you're sorted. 👍
Hi Everyone, how u guys doing?
In the past couple days I've been developing my API using hapi-auth-jwt2 and it was wonderful. However, when I create the docker container and run my server i could not verify the user token.
I'm using the RS256 algorithm and this is part of my code:
The private and the public key was generated inside the container with the following code:
openssl genrsa -out private.pem 2048
openssl rsa -in private.pem -pubout > public.pem
The error i get is this one:
I also insert a console log inside the hapi-auth-jwt2 module and get this error:
I would like to remember that in localhost is working perfect the only problem is in docker container.
Thanks!