PSKeePass / PoShKeePass

PowerShell module for KeePass
MIT License
256 stars 58 forks source link

Can not open database with both KeyFile and MasterKey - The composite key is invalid #205

Open xanthar opened 2 years ago

xanthar commented 2 years ago

Hi.

I create the profile:

New-KeePassDatabaseConfiguration -DatabaseProfileName default -DatabasePath "<VALIDPATHTO.KDBX>" -KeyPath "<ValidPathTo.keyx>" -UseMasterKey

I then try to get entries:

Get-KeePassEntry -DatabaseProfileName default |select *
KeePass Password: **********

I get the following error:

Exception calling "Open" with "3" argument(s): "The composite key is invalid! Make sure the composite key is correct and try again." At C:\Program Files\WindowsPowerShell\Modules\poshkeepass\2.1.3.0\PoShKeePass.psm1:2664 char:9

InvalidDatabaseConnectionException : The database is not open. At C:\Program Files\WindowsPowerShell\Modules\poshkeepass\2.1.3.0\PoShKeePass.psm1:2669 char:13

I have tried without the -MasterKey switch. Also i am sure the paths to the files are correct and the password (Masterkey) entered is correct (Have checked, double and trippel checked in KeePass directly).

The only way i can get this to work is to remove the KeyFile completely from the database. But i would like this option for extra security measures since the database is used by administrator team.

What am i doing wrong here? As mentioned the KeyFile(.keyx), the .kdbx file and the masterkey has been verified directly with KeePass.

xanthar commented 2 years ago

I read this issue:https://github.com/PSKeePass/PoShKeePass/issues/191 and temporarily fixed it by also changing the KeyFile to version 1. But it would be great if this could be updated to work with V.2 keyfiles.

bjoernwendt commented 3 months ago

You have to set Paramater -UseMasterKey in the command for create the Profile The Documentation is not correct for Profile with MasterKey. New-KeePassDatabaseConfiguration -DatabaseProfileName 'KeyFileDB' -DatabasePath "Database.kdbx" -KeyPath "Database.keyx" -UseMasterKey

For Read use: ($psw = ps secure string) use:Get-KeePassEntry -KeePassEntryGroupPath 'Database/default' -AsPlainText -DatabaseProfileName KeyFileDB -MasterKey $psw This only works with key Version 1.

Lucian1000 commented 2 months ago

Hi guys

any updates on this one? We are currently facing the same problem