keepassxreboot / keepassxc-browser

KeePassXC Browser Extension
GNU General Public License v3.0
1.75k stars 183 forks source link

"Key exchange was not successful" for Brave/Chrome browsers. #1484

Closed HugoRebelo99 closed 2 years ago

HugoRebelo99 commented 2 years ago

Expected Behavior

Connect to database successfuly.

Current Behavior

Both on Chrome and Brave browser, whenever I try to connect to the database, this message is displayed: "Key exchange was not successful." Somehow the connection to the database doesn't seem to be working. I followed the troubleshooting guide provided, but also seems that it didn't got fixed. It's important to freeze, that I've installed Firefox to test the same behaviour, but was not reproducible. With Firefox I was able to connect to the database with no problems.

Possible Solution

Steps to Reproduce (for bugs)

  1. Click the KeePassXC extension on Brave/Chrome
  2. Press the "Reload" button
  3. The message "Key exchange was not successful." is displayed.

Debug info

KeePassXC - unknown KeePassXC-Browser - 1.7.10.1 Operating system: Win64 Browser: Chrome/Chromium 96.0.4664.45

varjolintu commented 2 years ago

Enable support for Chrome and/or Chromium too in KeePassXC. For some reason Brave doesn't always use its own configuration paths.

HugoRebelo99 commented 2 years ago

Don't know why you closed the issue already... The support for all browsers are enable, and still the issue persists...

varjolintu commented 2 years ago

1) Go through the https://github.com/keepassxreboot/keepassxc-browser/wiki/Troubleshooting-guide 2) Check for other Brave related issues: https://github.com/keepassxreboot/keepassxc-browser/issues?q=is%3Aissue+brave+is%3Aclosed

HugoRebelo99 commented 2 years ago

Already followed the troubleshoot guide, but didn't work. :/

varjolintu commented 2 years ago

Other things to check:

HugoRebelo99 commented 2 years ago

Yes keepassxc-proxy.exe is running. Otherwise Firefox would not be able to connect,

varjolintu commented 2 years ago

Yes. But is it running without Firefox with only Brave launched?

HugoRebelo99 commented 2 years ago

Ok, after all keepassxc-proxy.exe is not running. My bad... Although, even if I launch it from the installation folder, I'm not being able to connect from Brave/Chrome. What should I do?

varjolintu commented 2 years ago

The proxy should be launched when you browser is started, or when you press the Reload button from the extension popup. See the JavaScript Log/Console and see if there's any error messages related to this.

HugoRebelo99 commented 2 years ago

When I open Firefox the keepassxc-proxy.exe is running, although the same is not happening for Brave and Chrome. Also checked the Console and no errors were reported in there.

varjolintu commented 2 years ago

Even after Reload button? Try looking at the background script console. Go to brave://extensions/, enable the Developer mode from the upper right and then choose Inspect views from the KeePassXC-Browser extension card. Find the Console tab there.

HugoRebelo99 commented 2 years ago

Here is what I found: image

varjolintu commented 2 years ago

And everything is correct when you checked to registry locations and JSON script file contents when going through the Troubleshooting Guide?

varjolintu commented 2 years ago

Another thing you could check is that does Brave actually use now their own registry settings instead, meaning NativeMessagingHosts is found under Software/Brave etc.

Of course, that doesn't explain why you are also having problems with Chrome.

HugoRebelo99 commented 2 years ago

What is the value that should be set to HKEY_CURRENT_USER\\Software\\Google\\Chrome\\NativeMessagingHosts\\? And what is the registry path for Brave? At this moment, the value of the above registry is pointing to org.keepassxc.keepassxc_browser_chrome.json.

varjolintu commented 2 years ago

Like said in the Troubleshooting Guide, you should find that file in AppData\Local\keepassxc. Brave should point to the same location. I have no idea for the Brave's registry path because AFAIK they still use Chrome's registry paths for some reason.

HugoRebelo99 commented 2 years ago

I'll try to find Brave's registry path. Although the same console output is being displayed by Chrome even with all the paths being correct.

varjolintu commented 2 years ago

Double check that the JSON file actually exists that is mentioned in the registry. Compare the settings with Firefox.

HugoRebelo99 commented 2 years ago

The JSON files are all in the mentioned place: image

Content of org.keepassxc.keepassxc_browser_brave.json: image

Content of org.keepassxc.keepassxc_browser_chrome.json: image

Content of org.keepassxc.keepassxc_browser_firefox.json: image

HugoRebelo99 commented 2 years ago

So the JSON files are correct, and the path on the registry is also correct so I'm not sure why the connection cannot be done.

varjolintu commented 2 years ago

Where did you install the extension to your browsers? The hard way to see if Brave is trying to load the registry or script from correct location is to use: https://docs.microsoft.com/en-us/sysinternals/downloads/procmon

HugoRebelo99 commented 2 years ago

The registry location that is being loaded has the right location both for Brave and Chrome.

varjolintu commented 2 years ago

Just to make sure because you didn't include this in the issue template: what KeePassXC version are you using?

HugoRebelo99 commented 2 years ago

You're right, sorry about that. The KeePassXC version that I'm using is 2.6.6.

varjolintu commented 2 years ago

If the registry entries are correct, path are correct, files are loaded from correct paths (confirmed by Process Monitor), that only leaves the possibility of anti-virus or anti-malware software that prevents the launching of keepassxc-proxy.exe. Or if you are using a work computer, it has some restrictions. Otherwise I have no idea.

HugoRebelo99 commented 2 years ago

But even that shouldn't be the case since I'm able to make the connection using Firefox.

varjolintu commented 2 years ago

Does the process monitor show any errors related to keepassxc-proxy.exe? If it cannot be started for some reason, at least something should be shown there.

HugoRebelo99 commented 2 years ago

Can't find keepassxc-proxy.exeon the process monitor. :/

varjolintu commented 2 years ago

That probably means your browsers don't have some kind of permission to launch external applications.

Have you tried to search similar issues from elsewhere? I found for example this one: https://stackoverflow.com/questions/42552699/failed-to-start-native-messaging-host-on-windows-comspec-is-not-set

HugoRebelo99 commented 2 years ago

It worked! :D What I did was create insert that environment variable, restarted my system and now everything is working fine! Thank you very much for the support! <3

varjolintu commented 2 years ago

Phew!

HugoRebelo99 commented 2 years ago

Ahahah, this was a tough one.

varjolintu commented 2 years ago

That environment variable thing was totally new information for me. Glad I found it. I hope everyone else finds this issue if they have similar problem with their system.

ghost commented 2 years ago

Hello, Can I reopen this issue. I am using Linux - Pop_os. Whenever I try to connect to the Keepass database, I also get the following message: Cannot connect to KeePassXC. Check that browser integration is enabled in KeePassXC settings. The browser I'm using is Brave browser. the keepass extension works fine on Firefox.

Somehow the connection to the database doesn't seem to be working. I have also followed the troubleshooting guide provided, but that doesn't seem to fix it.

I'm not completely sure what @HugoRebelo99 done to fix it. Not sure what the environment variable is.

Debug info

KeePassXC - unknown KeePassXC-Browser - 1.7.11 Operating system: Linux x86_64 Browser: Chrome/Chromium 98.0.4758.102

varjolintu commented 2 years ago

@TyrionGit Check that you are not running Brave as Snap or Flatpak.

ghost commented 2 years ago

@varjolintu I didn't download the Snap or Flatpak version. I downloaded from the website.

varjolintu commented 2 years ago

@TyrionGit Then report here where the script files are installed and where's your Brave config. Use strace if possible to detect and confirm it.

ghost commented 2 years ago

@varjolintu Do you mean the Json file? - org.keepassxc.keepassxc_browser.json That is stored here: /.var/app/org.keepassxc.KeePassXC/config/BraveSoftware/Brave-Browser/NativeMessagingHosts

I'm afraid I'm new to using Terminal so I'm not sure how to use the strace command to find where the script files are.

varjolintu commented 2 years ago

@TyrionGit That's not the default path. Those are described in the Troubleshooting Guide. Create a symbolink link or copy the file to the correct location which is probably under .config. Or then just try to enable Chrome & Chromium support in KeePassXC. Sometimes (don't know why) Brave uses those settings instead.

ghost commented 2 years ago

Thanks @varjolintu . This has worked.

I copied the Json file from that previous location to .config/BraveSoftware/Brave-Browser/NativeMessagingHosts. I then refreshed the browser window, at which point the extension asked me to name the connection. I've now got a connection.

Thanks so much for your help!