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

The composite key is invalid! Make sure the composite key is correct and try again #191

Open
sgreci opened this issue Jan 28, 2021 · 2 comments

Comments

@sgreci
Copy link

sgreci commented Jan 28, 2021

Hello,
i'm testing PoShKeePass with key files. I've created through the KeePass 2 windows interface a new database and configured the access only with a keyfile.

I created a KeePassDatabaseConfiguration:

New-KeePassDatabaseConfiguration -DatabasePath "C:\Projects\keepass\database1.kdbx" -DatabaseProfileName "profile1" -KeyPath "C:\Projects\keepass\database1.keyx"

and this is the result:

PS C:\Users\sgrec> Get-KeePassDatabaseConfiguration

DatabasePath       : C:\Projects\keepass\database1.kdbx
Default            : False
Name               : profile1
UseMasterKey       : False
KeyPath            : C:\Projects\keepass\database1.keyx
AuthenticationType : Key
UseNetworkAccount  : False

When i try to open the database and read an entry i got this error:

PS C:\Users\sgrec> Get-KeePassEntry -Title "localhost_user1" -DatabaseProfileName profile1
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
+         $null = $DatabaseObject.Open($IOInfo, $CompositeKey, $IStatus ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : InvalidCompositeKeyException

InvalidDatabaseConnectionException : The database is not open.
At C:\Program Files\WindowsPowerShell\Modules\PoShKeePass\2.1.3.0\PoShKeePass.psm1:2669 char:13
+             Throw 'InvalidDatabaseConnectionException : The database  ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (InvalidDatabase...se is not open.:String) [], RuntimeException
    + FullyQualifiedErrorId : InvalidDatabaseConnectionException : The database is not open.

Really don't understand what's going on because from KeePass 2 GUI I can open the database and read/write entries. Here below my versions:

Name                           Value
----                           -----
PSVersion                      5.1.19041.610
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.610
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

KeePass 2 2.47
PoShKeePass 2.1.3.0

@marayas
Copy link

marayas commented May 13, 2021

Same issue for me, but I'm not using a keyfile.

1.- If i pass the password manually it works
2.- If i used the System.Security.SecureString doesn't work and get the same error

PS D:\gdlrayas\GitLab\marco-wintel-scripts> Get-KeePassEntry -DatabaseProfileName 'TEST' -MasterKey $PWord
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

  •     $null = $DatabaseObject.Open($IOInfo, $CompositeKey, $IStatus ...
    
  •     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    • FullyQualifiedErrorId : InvalidCompositeKeyException

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

  •         Throw 'InvalidDatabaseConnectionException : The database  ...
    
  •         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : OperationStopped: (InvalidDatabase...se is not open.:String) [], RuntimeException
    • FullyQualifiedErrorId : InvalidDatabaseConnectionException : The database is not open.

@emichnie
Copy link

I had similar issue. My initial keyfile, I've generated using Format version 2.0(recommended). However, when I've generated new keyfile using Format Version 1.0(compatible with older KeePass version/ports) I was able to use PoShKeePass with keyfile.
KeyFile-FormatVersion-1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants