sqlectron / sqlectron-gui

A simple and lightweight SQL client desktop with cross database and platform support.
https://sqlectron.github.io/
MIT License
4.57k stars 524 forks source link

SQLECTRON_SECRET relatived error #321

Closed gluefxu closed 7 years ago

gluefxu commented 7 years ago

just clone the newest version 1.20.2

  1. When run "npm run dev", I cann't connect to the DB(old version 1.3.0 is OK) and the UI shows "Connection Error Bad input string". and the console shows a "CONNECTION_FAILURE" log,

Error: Bad input string at Decipher.update (crypto.js:144:26) at Object.decrypt (xxx/sqlectron-gui/node_modules/sqlectron-core/lib/crypto.js:33:22) at decryptSecrects (xxx/sqlectron-gui/node_modules/sqlectron-core/lib/servers.js:148:30) at xxx/sqlectron-gui/node_modules/sqlectron-core/lib/servers.js:14:14 at Array.forEach (native) at Object. (xxx/sqlectron-gui/node_modules/sqlectron-core/lib/servers.js:13:20) at Generator.next () at step (xxx/sqlectron-gui/node_modules/sqlectron-core/lib/servers.js:111:191) at xxx/sqlectron-gui/node_modules/sqlectron-core/lib/servers.js:111:361

  1. And when i run "npm run dev", replace-secret.js throw a "Missing SQLECTRON_SECRET" error.

They seems related. I have no idea after searching(a lot of thing in sqlectron-core). So what is the "secret" mean? Where is the SQLECTRON_SECRET come from?

Thank you! (Sorry for my poor English)

maxcnunes commented 7 years ago

In the next version the secret values (passwords) in ~/.sqlectron.json will be encrypted. The SQLECTRON_SECRET is the secret used to encrypt and decrypt the passwords. But replace-secret.js is only executed in the build. You shouldn't have that problem with npm run dev.

maxcnunes commented 7 years ago

Although that problem wasn't happening to me. I have simplified the code to not depend on SQLECTRON_SECRET anymore. Closing this issue. Please re open if it still happening to you.