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

IPv6 host: OpenError: The operation failed for reasons unrelated to the database itself and not covered by any other error code. #2017

Closed
pruflyos opened this issue May 4, 2019 · 5 comments

Comments

@pruflyos
Copy link

pruflyos commented May 4, 2019

  • Version: 0.35.0
  • Platform: Firefox 66.0.3 (64-bit)
  • Subsystem:

Type: Bug

Severity: High

Description:

I have a OpenWrt uHTTPd server which is reachable on both IPv4 and IPv6 address. If I put the example file from https://github.com/ipfs/js-ipfs/tree/master/examples/browser-script-tag on that server and access it via IPv4 (http://192.168.1.1/jsipfstest.html) everything is fine. But if I access the same file via IPv6 (http://[6001:3ff0:6dae:0:4819:b1bb:c001:22ac]/jsipfstest.html) the node is not started and the following error is shown in the browser console:

OpenError: The operation failed for reasons unrelated to the database itself and not covered by any other error code.

Steps to reproduce the error:

  1. Have a webserver which is reachable on both - IPv4 and IPv6 address.
  2. Put the example from https://github.com/ipfs/js-ipfs/tree/master/examples/browser-script-tag on that webserver.
  3. Access the example via IPv4. It works!
  4. Access the example via IPv6. It doesn't work!
@alanshaw
Copy link
Member

alanshaw commented May 9, 2019

Was there a stack trace with that error?

@alanshaw
Copy link
Member

ping @pruflyos

@alanshaw
Copy link
Member

I do not get that error but this works for me in Firefox:

Screenshot 2019-05-14 at 09 58 14

...but is not considered secure in Chrome and I think we're not properly detecting secure context so webcrypto is failing:

Screenshot 2019-05-14 at 09 58 11

@lidel have you seen this before? Shall we open an issue on libp2p-crypto?

@lidel
Copy link
Member

lidel commented May 14, 2019

@alanshaw it is a known issue with WebCrypto: it requires Secure Context (deploy over HTTPS or localhost IP). Firefox does not implement secure context requirement for it yet, but there is an open issue to do it.

tl;dr to test this without triggering secure context check in Chrome, load test page from localhost IPv6:

http://[::1]:8000/ipfs.html

Upstream issues:

alanshaw pushed a commit to libp2p/js-libp2p-crypto that referenced this issue Jul 9, 2019
Changes `webcrypto.js` to check for native web crypto availability and falls
back to using `window.__crypto` if not available.

If the user wants to bring their own Web Crypto API compatible implementation
then they simply need to assign it to `window.__crypto` before they start using
IPFS.

Checks are done in the functions that require web crypto to give the user the
flexibility to assign to `window.__crypto` before OR after they import
`libp2p-crypto`. It also means that users have the ability to use other exported
functions that do not require web crypto without having to worry about sorting
their own implementation.

We use `window.__crypto` because `window.crypto` is a readonly property in
secure context and always readonly in workers.

If `window.crypto` and `window.__cypto` are unavailable then an appropriate
error message is reported to the user with a `ERR_MISSING_WEB_CRYPTO` code.

I've also added documentation to the README.

This is a backwards compatible change.

closes #149
resolves #105
resolves ipfs/js-ipfs#2017
resolves ipfs/js-ipfs#2153

License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
alanshaw added a commit to libp2p/js-libp2p-crypto that referenced this issue Jul 17, 2019
This PR simply detects missing web crypto and throws an error with an appropriate message.

This is a stepping stone that will help users understand the problem until we have time to do a refactor of this module and of all the modules that use it to enable optionally passing your own crypto implementation.

refs #149
refs #150
refs #105
refs ipfs/js-ipfs#2153
refs ipfs/js-ipfs#2017

License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
@alanshaw
Copy link
Member

A better error message will be displayed in future versions of libp2p-crypto libp2p/js-libp2p-crypto#157

At some point we'll allow passing your own crypto implementation when in insecure contexts (for when you really really still need to do crypto), but that requires a big refactor of the module and of many modules that use it.

Considering this particular problem solved for now!

jacobheun pushed a commit to libp2p/js-libp2p-crypto that referenced this issue Jul 22, 2019
This PR simply detects missing web crypto and throws an error with an appropriate message.

This is a stepping stone that will help users understand the problem until we have time to do a refactor of this module and of all the modules that use it to enable optionally passing your own crypto implementation.

refs #149
refs #150
refs #105
refs ipfs/js-ipfs#2153
refs ipfs/js-ipfs#2017

License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
Mikerah pushed a commit to ChainSafe/js-libp2p-crypto that referenced this issue Aug 29, 2019
This PR simply detects missing web crypto and throws an error with an appropriate message.

This is a stepping stone that will help users understand the problem until we have time to do a refactor of this module and of all the modules that use it to enable optionally passing your own crypto implementation.

refs libp2p#149
refs libp2p#150
refs libp2p#105
refs ipfs/js-ipfs#2153
refs ipfs/js-ipfs#2017

License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants