dbeaver-creds 0.1.1
Decrypt DBeaver credentials-config.json.
Loading...
Searching...
No Matches
dbeaver-creds.h File Reference

Go to the source code of this file.

Enumerations

enum  dbeaver_credentials_error {
  DBEAVER_CREDENTIALS_OK = 0 , DBEAVER_CREDENTIALS_PATH_UNAVAILABLE , DBEAVER_CREDENTIALS_FILE_READ_FAILED , DBEAVER_CREDENTIALS_INVALID_CIPHERTEXT ,
  DBEAVER_CREDENTIALS_DECRYPTION_FAILED , DBEAVER_CREDENTIALS_EMPTY_PAYLOAD , DBEAVER_CREDENTIALS_OUT_OF_MEMORY
}
 Error codes written through the err out-parameter of get_dbeaver_credentials. More...

Functions

char * get_dbeaver_credentials (const char *path, enum dbeaver_credentials_error *err)
 Read DBeaver's credentials-config.json, decrypt it, and return the JSON payload as a malloc-allocated, NUL-terminated UTF-8 string.

Enumeration Type Documentation

◆ dbeaver_credentials_error

Error codes written through the err out-parameter of get_dbeaver_credentials.

Enumerator
DBEAVER_CREDENTIALS_OK 

Operation succeeded.

DBEAVER_CREDENTIALS_PATH_UNAVAILABLE 

The platform-default credentials path could not be determined.

DBEAVER_CREDENTIALS_FILE_READ_FAILED 

The credentials file could not be opened or fully read.

DBEAVER_CREDENTIALS_INVALID_CIPHERTEXT 

The ciphertext was empty or not a multiple of the AES block size.

DBEAVER_CREDENTIALS_DECRYPTION_FAILED 

The crypto backend rejected the ciphertext during decryption.

DBEAVER_CREDENTIALS_EMPTY_PAYLOAD 

Decryption produced no JSON payload after the IV prefix.

DBEAVER_CREDENTIALS_OUT_OF_MEMORY 

A heap allocation failed while assembling the result.

Function Documentation

◆ get_dbeaver_credentials()

char * get_dbeaver_credentials ( const char * path,
enum dbeaver_credentials_error * err )

Read DBeaver's credentials-config.json, decrypt it, and return the JSON payload as a malloc-allocated, NUL-terminated UTF-8 string.

If path is NULL, the platform-default location is used:

  • Linux: $XDG_DATA_HOME/DBeaverData/... (or $HOME/.local/share/...)
  • macOS: $HOME/Library/DBeaverData/...
  • Windows: APPDATA%\\DBeaverData\\...

The caller owns the returned buffer and must release it with free().

Parameters
[in]pathconst char * - Filesystem path to the credentials file, or NULL to use the platform-default location.
[out]errenum dbeaver_credentials_error * - Receives the result code (DBEAVER_CREDENTIALS_OK on success, otherwise one of the failure codes). May be NULL to ignore.
Returns
char * - Newly allocated, NUL-terminated UTF-8 JSON string on success, or NULL on failure.