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.
Will put up a website in a second.
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
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.