Search code examples
javascriptkeepass

Accessing keepass databass returns KdbxError: Error BadSignature


I am using the kdbxweb library. My goal is to open a kdbx database file, and then retrieve a password from it. Following the example on the page, and also inspired by some things I saw in the keepass code, which uses this lib, I came up with this:

  const password = kdbxweb.ProtectedValue.fromString('secret');

  const credentials = new kdbxweb.Credentials(password);

  const file = kdbxweb.ByteUtils.arrayToBuffer(
    kdbxweb.ByteUtils.base64ToBytes('/home/chai/code/Kairos/src/e2e/db.kdbx'),
  );

  const db = await kdbxweb.Kdbx.load(file, credentials);

Sadly when I run it it gives me : Error | KdbxError: Error BadSignature

The file and password are correct; I verified that using the keepass application, which will open it without issue.

Any ideas are welcome! Thx!


Solution

  • Okay I found out what the problem was. It was in the structure of the keepass kdbx file. It was generated by importing a csv, but somehow all entries were directly under root. This gave me errors. Now restructuring it with a Group "db" (as per default) and then putting the entries under that solved the issue.