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

Can't set 2FA because of "Invalid key length" #8017

Closed
KaratekHD opened this issue Mar 29, 2023 · 4 comments
Closed

Can't set 2FA because of "Invalid key length" #8017

KaratekHD opened this issue Mar 29, 2023 · 4 comments
Labels
🐛 bug Something isn't working

Comments

@KaratekHD
Copy link

Issue Summary

As per #7914, it seems like admins need to have 2FA enabled. However, when trying to enable 2FA, the user only sees "Something went wrong.".

image

Steps to Reproduce

  1. Sign in to your cal.com instance
  2. Click on Settings → Two factor auth
  3. Check "Two factor authentication"
  4. Enter your password
  5. Click "Continue"

Technical details

  • Browser Version: Firefox 109.0.1 and Edge 112.0.1698.0 on openSUSE Tumbleweed
  • Cal.com Docker container v2.7.6
  • server log:
@calcom/web:start: RangeError: Invalid key length
@calcom/web:start:     at Cipheriv.createCipherBase (node:internal/crypto/cipher:122:19)
@calcom/web:start:     at Cipheriv.createCipherWithIV (node:internal/crypto/cipher:141:3)
@calcom/web:start:     at new Cipheriv (node:internal/crypto/cipher:249:3)
@calcom/web:start:     at Object.createCipheriv (node:crypto:141:10)
@calcom/web:start:     at symmetricEncrypt (/calcom/apps/web/.next/server/chunks/8650.js:29:66)
@calcom/web:start:     at handler (/calcom/apps/web/.next/server/pages/api/auth/two-factor/totp/setup.js:329:107)
@calcom/web:start:     at async Object.apiResolver (/calcom/node_modules/next/dist/server/api-utils/node.js:372:9)
@calcom/web:start:     at async NextNodeServer.runApi (/calcom/node_modules/next/dist/server/next-server.js:513:9)
@calcom/web:start:     at async Object.fn (/calcom/node_modules/next/dist/server/next-server.js:815:35)
@calcom/web:start:     at async Router.execute (/calcom/node_modules/next/dist/server/router.js:243:32)
@calcom/web:start:     at async NextNodeServer.runImpl (/calcom/node_modules/next/dist/server/base-server.js:432:29)
@calcom/web:start:     at async NextNodeServer.handleRequestImpl (/calcom/node_modules/next/dist/server/base-server.js:375:20)
@calcom/web:start:     at async /calcom/node_modules/next/dist/server/base-server.js:157:99 {
@calcom/web:start:   code: 'ERR_CRYPTO_INVALID_KEYLEN'
@calcom/web:start: }
  • The browser tries to post to /api/auth/two-factor/totp/setup, which results in HTTP 500 (Internal Server Error)
@maige-app maige-app bot added the 🐛 bug Something isn't working label Mar 29, 2023
@rusty1281
Copy link

I have the same exact error using the 2.7.9 version.

@lpadula
Copy link

lpadula commented Apr 13, 2023

Same problem here!

@eduardstal
Copy link

eduardstal commented Apr 13, 2023

Same problem here using 2.7.15

--
Fixed:

Make sure to use rand -base64 32 for NEXTAUTH_SECRET
And rand -base64 24 for CALENDSO_ENCRYPTION_KEY

And not the other way around, like I did.

@sneridagh
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants