Js-ipfs: Uncaught TypeError: Cannot read property 'generateKey' of undefined

Created on 27 Aug 2017  路  9Comments  路  Source: ipfs/js-ipfs

  • Version: ipfs/js-ipfs
  • Platform: AWS EC2 Linux instance
  • Subsystem: Webcrypto, Chrome 60.0.3112.101

Type: Bug

Severity: High

Description: When trying to connect to IPFS on an amazon ec2 instance, I get the error:

Uncaught TypeError: Cannot read property 'generateKey' of undefined.

It seems like it's coming from the webcrypto package. But it's weird because it works locally for me, it's only when I deploy to ec2 that all of a sudden things go haywire.

I also get the error:

Uncaught Error: Callback was already called.

Steps to reproduce the error:

Will put up a website in a second.

Most helpful comment

TIL that WebCrypto is restringed to HTTPS pages It seems that WebCrypto does require a secure context to run and that is not granted in non HTTPS loaded pages. It has an exception for localhost though.

Apologies @lightninglu10, you are totally right. It is a HTTPS/HTTP issue.

All 9 comments

Found the error: it seems like we need to deploy over HTTPS for IPFS to work. @diasdavid can you confirm this is the case?

@lightninglu10 HTTP or HTTPS should not be related. Note that the code is running in your browser and dialing to an IPFS node running in Node.js, correct?

What is the version of Node.js running in your EC2 instance?

The code is running in my browser but dialing to an IPFS node running in Go.

I think the HTTPS/HTTP is relevant as I only ran into this error:

Uncaught TypeError: Cannot read property 'generateKey' of undefined.

from the browser's native webcrypto
on regular HTTP network. Through HTTPS, I don't get that error.

@lightninglu10 is your go endpoint behind a SSL termination proxy? //cc @lgierth who can share some tricks here :)

@lightninglu10 is your go endpoint behind a SSL termination proxy? //cc @lgierth who can share some tricks here :)

Do note that if this was really an HTTPS issue, the browser node should fail dialing on the transport and would never get to SECIO (which is where that generateKey happens). I'm intrigued by how you have things set up as I'm not figuring out what is the codepath you are hitting in your particular situation.

Not sure if they are related but I reported a bug in the shared-editor repo which may be the same one https://github.com/ipfs-shipyard/shared-editing-demo/issues/4 . Note - it occurs in recompiled code, not the one in that repo. That one also only occurs when working remote, but not locally.

TIL that WebCrypto is restringed to HTTPS pages It seems that WebCrypto does require a secure context to run and that is not granted in non HTTPS loaded pages. It has an exception for localhost though.

Apologies @lightninglu10, you are totally right. It is a HTTPS/HTTP issue.

Opened a issue to discuss and reach a conclusion for the preferred solution https://github.com/libp2p/js-libp2p-crypto/issues/105

Let's track it there

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lifeBCE picture lifeBCE  路  3Comments

dryajov picture dryajov  路  3Comments

beingmohit picture beingmohit  路  3Comments

daviddias picture daviddias  路  3Comments

lidel picture lidel  路  3Comments