Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

UnhandledPromiseRejectionWarning: Error: Key management requires '--pass ...' option #1891

Closed
@R9295

Description

@R9295

Version: v34.4.4
Platform: Linux 4.9.0-7-amd64 #1 SMP Debian 4.9.110-3+deb9u2 (2018-08-13) x86_64 GNU/Linux
Subsystem: libp2p-keychain

Type: Bug

Severity: ?

Description:

Empty/default passphrase on init leads to no keychain being found.

Steps to reproduce the error:

The following code

const ipfs = require("ipfs");
const port = 1544;
const node = new ipfs({
  repo: `./ipfs/${port}`,
  EXPERIMENTAL: {
    pubsub: true,
    dht: true
  },
  pass: "",
});

node.on("ready", async (err, id) => {
  if (err) {
    conole.log(err);
  }
 console.log(await node.key.list())
}

results in

(node:2750) UnhandledPromiseRejectionWarning: Error: Key management requires '--pass ...' option
    at fail (/home/aarnav/Desktop/code_berlin/node_modules/ipfs/src/core/components/no-keychain.js:4:9)
    at NoKeychain.createKey (/home/aarnav/Desktop/code_berlin/node_modules/ipfs/src/core/components/no-keychain.js:11:18)
    at Function.gen.promisify (/home/aarnav/Desktop/code_berlin/node_modules/ipfs/src/core/components/key.js:11:22)

I checked out the node object and it's _keychain property was NoKeyChain{}.
Then, I tried to create a keychain object myself with libp2p-keychain and the node's properties by following the code here:

const keychainOptions = Object.assign({passPhrase: opts.pass}, config.Keychain)
self._keychain = new Keychain(self._repo.keys, keychainOptions)

And voilà! I get an error:

(node:3108) UnhandledPromiseRejectionWarning: Error: passPhrase must be least 20 characters

After setting my pass value in the node's config to a string with more than twenty characters and reinitializing, I was able to successfully list my keys.

Also, I think this issue could add to #1138

Metadata

Metadata

Assignees

Labels

P3Low: Not priority right nowexp/noviceSomeone with a little familiarity can pick upkind/bugA bug in existing code (including security flaws)kind/resolved-in-heliastatus/readyReady to be worked

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions