Closed philxws692 closed 1 month ago
Hi @philxws692
would you be able to provide an example KDBX file with the same DB settings with which you can also recreate the issue? It will make the investigation a lot easier.
Best, Tobias
Woah that was fast,
I can provide you the exact database, as this is only a database used for testing š database.kdbx.zip
Password is: test1234 for simplicity
Best regards Philipp
Thank you
I will probably not be able to debug it immediately, but it helps to ask for needed input quickly š
I'll let you know what I find
Yeah no worries, it is not that important, as I also have not a lot time for this project š
But thank you already for your future debugging š„³
I believe I found the issue š
Your example would probably look something like this:
package main
import (
"fmt"
"log"
"os"
"github.com/tobischo/gokeepasslib"
)
func main() {
path := "./database.kdbx"
file, _ := os.Open(path)
db := gokeepasslib.NewDatabase()
db.Credentials = gokeepasslib.NewPasswordCredentials("test1234")
err := gokeepasslib.NewDecoder(file).Decode(db)
if err != nil {
log.Fatal(err)
}
db.UnlockProtectedEntries()
// Note: This is a simplified example and the groups and entries will depend on the specific file.
// bound checking for the slices is recommended to avoid panics.
entry := db.Content.Root.Groups[0].Entries[0]
fmt.Println(entry.GetTitle())
fmt.Println(entry.GetPassword())
}
and it should look like this:
package main
import (
"fmt"
"log"
"os"
"github.com/tobischo/gokeepasslib/v3"
)
func main() {
path := "./database.kdbx"
file, _ := os.Open(path)
db := gokeepasslib.NewDatabase()
db.Credentials = gokeepasslib.NewPasswordCredentials("test1234")
err := gokeepasslib.NewDecoder(file).Decode(db)
if err != nil {
log.Fatal(err)
}
db.UnlockProtectedEntries()
// Note: This is a simplified example and the groups and entries will depend on the specific file.
// bound checking for the slices is recommended to avoid panics.
entry := db.Content.Root.Groups[0].Entries[0]
fmt.Println(entry.GetTitle())
fmt.Println(entry.GetPassword())
}
The subtle difference is whether you are using github.com/tobischo/gokeepasslib
or github.com/tobischo/gokeepasslib/v3
Ahh perfect, thanks for your fast response, I changed it to github.com/tobischo/gokeepasslib/v3
and now it's working fine. Did not thought that this would make such a big difference š
Thank you very much
Generally it shouldn't have made a difference, so I think that was a valid assumption.
However, when I put the very first version of this library onto github, it only supported format version 3.1 as that was what I was using at the time. Before adding support for kdbx 4.0 some other breaking changes were introduced, resulting in major version changes š
Glad to read that it is working now
Hey all,
I just stumbled upon this great project as I was searching for a way to build myself a little CLI tool for my keepass database. However when im trying to read the database I get the following error:
gokeepasslib: invalid signature. Minor Version is 0. Should be 1
The error occurs when decoding the database. My code for decoding the database is taken from the example code and looks like this
The path I enter is corrected and refers to my home folder. I already tried changing the wanted Minor Version in order to see if this will work, but I ended up with another signature error:
gokeepasslib: invalid signature. Base Signature is 7b226461. Should be 03d9a29a
So I decided to check the wanted signature and if it exists in the database, which it does:
I really don't know where the issue is. The database version is KDBX 4.0 and was created with KeepassXC Version 2.7.9
Any help would be really appreciated, thanks :)
Best regards Philipp