Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Cannot read property 'importKey' #153

Closed
oscartbeaumont opened this issue Aug 26, 2018 · 50 comments
Closed

Error: Cannot read property 'importKey' #153

oscartbeaumont opened this issue Aug 26, 2018 · 50 comments
Labels
wontfix This will not be worked on

Comments

@oscartbeaumont
Copy link

Hello,
I just came across this project and installed it using the command in the README. When I try to login I get the error below. The error below is copied from the Chromes devtools console. Have I done something wrong or is this a bug?

core.js:1440 ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'importKey' of null
TypeError: Cannot read property 'importKey' of null
    at n.<anonymous> (webCryptoFunction.service.ts:45)
    at zohoVaultCsvImporter.ts:7
    at Object.next (zohoVaultCsvImporter.ts:7)
    at zohoVaultCsvImporter.ts:7
    at new t (zone.js:887)
    at t (zohoVaultCsvImporter.ts:7)
    at n.pbkdf2 (webCryptoFunction.service.ts:25)
    at n.<anonymous> (crypto.service.ts:276)
    at container.service.ts:4
    at Object.next (container.service.ts:4)
    at n.<anonymous> (webCryptoFunction.service.ts:45)
    at zohoVaultCsvImporter.ts:7
    at Object.next (zohoVaultCsvImporter.ts:7)
    at zohoVaultCsvImporter.ts:7
    at new t (zone.js:887)
    at t (zohoVaultCsvImporter.ts:7)
    at n.pbkdf2 (webCryptoFunction.service.ts:25)
    at n.<anonymous> (crypto.service.ts:276)
    at container.service.ts:4
    at Object.next (container.service.ts:4)
    at O (zone.js:821)
    at zone.js:736
    at r (register.component.html:53)
    at t.invoke (zone.js:388)
    at Object.onInvoke (core.js:4733)
    at t.invoke (zone.js:387)
    at e.run (zone.js:138)
    at zone.js:870
    at t.invokeTask (zone.js:421)
    at Object.onInvokeTask (core.js:4724)```
@mprasil mprasil added question Further information is requested, or question from user troubleshooting There might be bug or it could be user error, more info needed labels Aug 26, 2018
@mprasil
Copy link
Contributor

mprasil commented Aug 26, 2018

Hi, the console error probably isn't going to be as useful as network view. Try to see if there are any failing requests in the network tab of dev tools. Also do check the logs on the server side. You can post those here. (obviously replacing any sensitive data)

Also can you share the exact command you used to run bitwarden_rs?

@oscartbeaumont
Copy link
Author

It is not making any web request, It must be failing before that occurs. The command I used to start the server is

docker run -d --name bitwarden -v /bw-data/:/data/ -p 8080:80 mprasil/bitwarden:latest

It is weird because I just checked and safari (on the same system) works fine but Chrome fails with the registration (it freezes on the submit button) and the login screen. I am on a Mac if that helps. I also disabled all of my extensions and that hasn't helped.

@mprasil
Copy link
Contributor

mprasil commented Aug 26, 2018

Try to go to the login screen, open the network tab and press ctrl-shift+r to do a full reload. See if any of the requests fail. Perhaps some static file didn't load properly or something like that. It looks like browser/client issue to me, but don't know enough javascript to be sure here.

@oscartbeaumont
Copy link
Author

Everything loads successfully. The last 2 request in the attached image are run when I click submit for the first time after the reload. The second time I click it nothing happens. Both times cause the error popup and it has stopped logging the error to the browser console.
screen shot 2018-08-26 at 7 48 30 pm

@mprasil
Copy link
Contributor

mprasil commented Aug 26, 2018

I suppose it still doesn't log you in though? Does the official Vault work for you? (https://vault.bitwarden.com)

@oscartbeaumont
Copy link
Author

I have a self-hosted instance of the official Bitwarden running and the login works perfectly.

@mprasil
Copy link
Contributor

mprasil commented Aug 26, 2018

What version of chrome are you using. I've tried to reduce this with Chromium version 68.0.3440.106 on Ubuntu and it just works for me 😕

@oscartbeaumont
Copy link
Author

I Am Running Google Chrome 68.0.3440.106 (Official Build) (64-bit) Revision 1c32c539ce0065a41cb79da7bfcd2c71af1afe62-refs/branch-heads/3440@{#794}
On MacOS 10.12.6.

@oscartbeaumont
Copy link
Author

It is also happening on a windows system with the same chrome version.

@mprasil
Copy link
Contributor

mprasil commented Aug 26, 2018

Is there any proxy in between or anything like that?

@oscartbeaumont
Copy link
Author

No not currently but I will add one when I deploy this in the future.

@mprasil
Copy link
Contributor

mprasil commented Aug 26, 2018

Do you have any domain configured or you access it by IP?

@oscartbeaumont
Copy link
Author

oscartbeaumont commented Aug 26, 2018

IP and HTTP. I am currently updating Docker on a second system and I will try running the server there and see if it works.

@oscartbeaumont
Copy link
Author

It works when hosted on another machine. So I am going to reinstall it to my server and see if that fixes it.

@mprasil
Copy link
Contributor

mprasil commented Aug 26, 2018

Make sure you pull the latest image!

@oscartbeaumont
Copy link
Author

I repulled the image from docker and it still didn't work but I created a new VM (Cloned from a base Image), installed docker and it didn't work. My server is running Debian and that could be causing an issue or my base vm has something it doesn't like or it does like being run inside a vm but docker has been working fine for other stuff.

@mprasil
Copy link
Contributor

mprasil commented Aug 26, 2018

Seems very unlikely that host OS would affect web interface in such way. Maybe a different docker version? (even that sounds kinda unlikely) I tried couple different setups here and failed to reproduce your issue. 😕

@ghost
Copy link

ghost commented Aug 27, 2018

I had the same problem on Google Chrome, after switch to Firefox problem gone. I wrote about it here
I thought it was server slow response

@mprasil
Copy link
Contributor

mprasil commented Aug 27, 2018

Hi, I've built mprasil/bitwarden:beta which is using latest Vault from master. Can you test that one and see if you still get any issues?

@oscartbeaumont
Copy link
Author

oscartbeaumont commented Aug 27, 2018

I installed the beta container and am getting the error on the account signing up page and submitting a correct login page. The login had to b created through Safari which isn't suffering this bug.
Also It is now making web requests when I submit a login and they are returning a correct login not an error.

@mprasil
Copy link
Contributor

mprasil commented Aug 27, 2018

What web request does it make when trying to log in?

@oscartbeaumont
Copy link
Author

oscartbeaumont commented Aug 27, 2018

POST /api/accounts/prelogin
It Returned With The Status 200:
{"Kdf":0,"KdfIterations":5000}

@theazriel
Copy link

hi,
this issue looks only a chrome browser, with edge it works fine.

in chrome i get the follow issue:

This page includes a password or credit card input in a non-secure context. A warning has been added to the URL bar. For more information, see https://goo.gl/zmWq3m.

11core.js:1440 ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'importKey' of null
TypeError: Cannot read property 'importKey' of null
at n. (webCryptoFunction.service.ts:45)
at zohoVaultCsvImporter.ts:7
at Object.next (zohoVaultCsvImporter.ts:7)
at zohoVaultCsvImporter.ts:7
at new t (zone.js:887)
at t (zohoVaultCsvImporter.ts:7)
......

@Silver-Golden
Copy link

Same thing was happening for me on 2.2.0.
Upgraded to 2.2.1 and its still happening.

This is a clean install as well (just started testing it for my purporses)

@mprasil
Copy link
Contributor

mprasil commented Aug 28, 2018

@silveress, can you confirm, that this happens only in Chrome for you?

@oscartbeaumont
Copy link
Author

I just setup my bitwarden_rs on a testing subdomain so I could share it and see if that can help with debugging but after setting that up I noticed it was working. My server parses traffic through an Nginx Proxy which handles HTTPS termination automatically. I them tired setting the DOMAIN env variable and that didn't help. So I generated a self signed HTTPS cert and configured it with the ROCKET_TLS env variable and the issue when away. So it must be something to do with HTTP.

@Silver-Golden
Copy link

I can concur with @oscartbeaumont.

I set it up on a subdomain on my vps with letsencrypt certs and nginx reverse proxy.
Accessing it via the sub domain it worked perfectly.
Accessing directly via IP (no cert) and the issues returned.

And these issues only pop up on chrome (and chromium) so I presume it is something how chrom(ium) handles http sites.

@mprasil
Copy link
Contributor

mprasil commented Aug 31, 2018

I've reported it upstream to bring some awareness about this problem.

@mprasil
Copy link
Contributor

mprasil commented Aug 31, 2018

@CaptInsano I'm using Bitwarden with LetsEncrypt cert on reverse proxy and it works fine everywhere including Chrome. I can only reproduce the problem over HTTP, is it possible there are some other issues affecting your HTTPS connection? So far everyone reported, that it works for them over secure channel.

@mprasil mprasil added documentation Documentation is missing and removed question Further information is requested, or question from user troubleshooting There might be bug or it could be user error, more info needed labels Aug 31, 2018
@mprasil
Copy link
Contributor

mprasil commented Sep 1, 2018

Confirmed with Kyle, that this is intentional, we need to document this to avoid people reporting it as a bug.

@CaptInsano
Copy link

@mprasil

You are right about the Nginx reverse proxy w. LetsEncrypt cert over https.
It works correctly once I cleared my cache, I am sorry for that.

Good to have an answer anyway.

mprasil added a commit to mprasil/bitwarden_rs that referenced this issue Sep 3, 2018
dani-garcia added a commit that referenced this issue Sep 3, 2018
Add info on running over HTTP (documentation for #153)
@mprasil
Copy link
Contributor

mprasil commented Sep 3, 2018

The documentation was merged. I'm going to resolve this as wontfix, because it's just not supported upstream.

@mprasil mprasil closed this as completed Sep 3, 2018
@mprasil mprasil added wontfix This will not be worked on and removed documentation Documentation is missing labels Sep 3, 2018
@CorneliousJD
Copy link

Just dropping in for early 2019 to say that I just deployed this on unRAID docker container and since there's no way to access over HTTPS out of the box without setting up reverse proxy, it fails in Chrome to let you sign in or register a new user. Firefox and Edge worked fine.

Can you couple this with at least a way to access over HTTPS? Even if it's just a self-signed cert so users can at least get accounts created and then setup their own reverse proxy if they want to secure it?

FYI I almost decided to ditch this assuming it would NEVER work in Chrome, but sounds like once I reverse proxy it, it'll be fine. Working on that next.

@dani-garcia
Copy link
Owner

I'm not sure if including or generating self signed certificates ourselves is a good idea, there are a lot of external tools that would do a better job than us.

We should definitely mention this in the README, because a lot of users already hit this problem.

@CorneliousJD
Copy link

@dani-garcia - sounds good, With a quick bit of research I was able to solve the problem and I'm up and running with a super lightweight self-hosted option. Thanks for the hard work on this!

@hank
Copy link

hank commented Apr 20, 2019

Yeah another user here that ran into this. Could you make it so a warning or something pops up when this occurs? It's hard to figure out that you need HTTPS.

@mprasil
Copy link
Contributor

mprasil commented Apr 20, 2019

I think this should probably be implemented/reported upstream as it's client only issue?

@dani-garcia
Copy link
Owner

As far as I know upstream doesn't support HTTP at all, so I don't think it's of much use. I think it would be useful to include a warning somewhere, as the error message is quite cryptic, not sure if modifying the web vault is the best way though.

@mprasil
Copy link
Contributor

mprasil commented Apr 20, 2019

Ah right, I forgot they don't support it at all. I wonder if they'd accept PR with some user friendly error message anyways.

@ngloom
Copy link

ngloom commented Jun 23, 2020

in my case , error disappear after using https

@briceparmentier
Copy link

Hi there,
I'm facing the same issue, knowing that in my case I'm self-hosting it on a Raspberry PI.
It appears the same on several browsers, Firefox at home, Chrome and Edge at work.
On Chrome or Firefox, nothing happens at all, on Edge, I get kind of a red popup on the right side telling something went wrong (and nothing else).
I'm not using HTTPS, maybe that's the clue?
Thanks !

@meyerje
Copy link

meyerje commented Sep 14, 2020

Use https @briceparmentier

@briceparmentier
Copy link

briceparmentier commented Sep 15, 2020

Use https @briceparmentier

@meyerje I've been reading the Wiki here https://github.com/dani-garcia/bitwarden_rs/wiki/Enabling-HTTPS, which points to another page for how to create a personal certificate. It also say that If following that guide your ROCKET_TLS line could look like this: -e ROCKET_TLS='{certs="/ssl/bitwarden.crt",key="/ssl/bitwarden.key"}', but I'm missing the part of where to move the generated files (all certificates and keys and all the stuff from the second page) to the docker machine...
Anyone can help with this?
Thanks

thelittlefireman pushed a commit to thelittlefireman/bitwarden_rs that referenced this issue Mar 19, 2021
thelittlefireman pushed a commit to thelittlefireman/bitwarden_rs that referenced this issue Mar 19, 2021
Add info on running over HTTP (documentation for dani-garcia#153)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests