adonis5-jwt icon indicating copy to clipboard operation
adonis5-jwt copied to clipboard

Passphrase required for encrypted key

Open doanbaanh opened this issue 3 years ago • 1 comments

Hi. I try to use this package for authenticate in microservice. JWT token generated by Symfony app with passphrase. await auth.use('jwt').authenticate() except passphrase's error.

[1660925432779] ERROR (server/12898 on Ba-Anh-MacBook-Pro.local): Passphrase required for encrypted key
    err: {
      "type": "TypeError",
      "message": "Passphrase required for encrypted key",
      "stack":
          TypeError: Passphrase required for encrypted key
              at createPrivateKey (internal/crypto/keys.js:351:10)
              at JWTGuard.generateKey (/Users/doanbaanh/PhpStormProjects/gold/server/node_modules/adonis5-jwt/build/lib/Guards/JwtGuard.js:341:46)
              at JWTGuard.verifyToken (/Users/doanbaanh/PhpStormProjects/gold/server/node_modules/adonis5-jwt/build/lib/Guards/JwtGuard.js:392:29)
              at JWTGuard.authenticate (/Users/doanbaanh/PhpStormProjects/gold/server/node_modules/adonis5-jwt/build/lib/Guards/JwtGuard.js:118:36)
              at AppController.playerHistory (/Users/doanbaanh/PhpStormProjects/gold/server/app/Controllers/Http/AppController.ts:8:27)
              at Injector.callAsync (/Users/doanbaanh/PhpStormProjects/gold/server/node_modules/@adonisjs/fold/build/src/Ioc/Injector.js:124:30)
              at processTicksAndRejections (internal/process/task_queues.js:95:5)
      "code": "ERR_MISSING_PASSPHRASE",
      "status": 500
    }

How can I fix this? Thanks.

doanbaanh avatar Aug 19 '22 16:08 doanbaanh

Try to put the same private key that Syphony generated for you in your .env, under JWT_PRIVATE_KEY

maxgalbu avatar Aug 30 '22 13:08 maxgalbu