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

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

Closed
R9295 opened this issue Feb 21, 2019 · 2 comments
Assignees
Labels
exp/novice Someone with a little familiarity can pick up kind/bug A bug in existing code (including security flaws) kind/resolved-in-helia P3 Low: Not priority right now status/ready Ready to be worked

Comments

@R9295
Copy link

R9295 commented Feb 21, 2019

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

@alanshaw alanshaw added kind/bug A bug in existing code (including security flaws) exp/novice Someone with a little familiarity can pick up status/ready Ready to be worked P3 Low: Not priority right now labels Mar 6, 2019
@vasa-develop
Copy link
Member

vasa-develop commented Sep 7, 2019

For now(until this issue is resolved), this will work if the pass param is at least 20 characters long.

Here is an example:

let ipfs = await IPFS.create({
        pass: "01234567890123456789",
})

@whizzzkid
Copy link

whizzzkid commented May 31, 2023

js-ipfs is being deprecated in favor of Helia. You can follow the migration plan here #4336 and read the migration guide.

This issue has been resolved in Helia! if this does not address your concern please let us know by reopening this issue before 2023-06-05!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
exp/novice Someone with a little familiarity can pick up kind/bug A bug in existing code (including security flaws) kind/resolved-in-helia P3 Low: Not priority right now status/ready Ready to be worked
Projects
No open projects
Status: Done
Development

No branches or pull requests

4 participants