Windows Credential Manager Store
The Windows Credential Manager Store extension allows Galasa to securely read test credentials from Windows Credential Manager, providing a more secure alternative to storing credentials in plain text configuration files.
Prerequisites¶
- Windows 10 or later
- Galasa 1.0.0 or later
Configuration¶
1. Enable the OS Credentials Store¶
Follow the Enabling the OS Credentials Store instructions to enable the OS Credentials Store.
2. Add Credentials to Windows Credential Manager¶
Credentials must be added to Windows Credential Manager before Galasa can retrieve them. Each credential is stored as a generic credential with:
- Target Name:
galasa.credentials.{CREDENTIALS-ID} - User Name: Varies by credential type (see below)
- Password: The actual password, token, or JSON data
Supported Credential Types¶
Username + Password¶
Format:
- User Name: The username (e.g.,
MYUSER) - Password: The password
Example using Control Panel:
- Open Control Panel → User Accounts → Credential Manager
- Click "Windows Credentials" → "Add a generic credential"
- Set "Internet or network address" to:
galasa.credentials.SIMBANK - Set "User name" to:
MYUSER - Set "Password" to:
SYS1 - Click "OK"
Example using PowerShell:
Username Only¶
For scenarios where only a username is needed (no password).
Format:
- User Name:
username:{actual-username}(e.g.,username:MYUSER) - Password: Empty string or any placeholder
Example using Control Panel:
- Open Control Panel → User Accounts → Credential Manager
- Click "Windows Credentials" → "Add a generic credential"
- Set "Internet or network address" to:
galasa.credentials.USERNAME - Set "User name" to:
username:MYUSER - Set "Password" to any value (required by Windows)
- Click "OK"
Example using PowerShell:
Token Only¶
For API tokens, personal access tokens, or other token-based authentication.
Format:
- User Name:
token - Password: The token value
Example using Control Panel:
- Open Control Panel → User Accounts → Credential Manager
- Click "Windows Credentials" → "Add a generic credential"
- Set "Internet or network address" to:
galasa.credentials.TOKEN - Set "User name" to:
token - Set "Password" to the token value
- Click "OK"
Example using PowerShell:
Username + Token¶
Format:
- User Name:
username-token:{actual-username}(e.g.,username-token:myuser) - Password: The token value
Example using Control Panel:
- Open Control Panel → User Accounts → Credential Manager
- Click "Windows Credentials" → "Add a generic credential"
- Set "Internet or network address" to:
galasa.credentials.USERNAMETOKEN - Set "User name" to:
username-token:myuser - Set "Password" to the token value
- Click "OK"
Example using PowerShell:
cmdkey /generic:"galasa.credentials.USERNAMETOKEN" /user:"username-token:myuser" /pass:"abc123xyz789"
KeyStore (JSON Format)¶
For Java KeyStore credentials containing SSL/TLS certificates and private keys.
Format:
- User Name:
JSON(case-insensitive) - Password: JSON object with keystore properties
JSON Structure:
Supported KeyStore Types:
JKS- Java KeyStorePKCS12- PKCS#12 format
Example - Encoding a KeyStore:
# First, encode your keystore file to base64
$bytes = [System.IO.File]::ReadAllBytes("mykeystore.jks")
$base64 = [System.Convert]::ToBase64String($bytes)
# Create the JSON (single line, no line breaks)
$json = "{`"keystore`":`"$base64`",`"password`":`"keystorepass`",`"type`":`"JKS`"}"
# Add to Credential Manager
cmdkey /generic:"galasa.credentials.MYKEYSTORE" /user:"JSON" /pass:"$json"
Example using Control Panel:
- Open Control Panel → User Accounts → Credential Manager
- Click "Windows Credentials" → "Add a generic credential"
- Set "Internet or network address" to:
galasa.credentials.MYKEYSTORE - Set "User name" to:
JSON - Set "Password" to:
{"keystore":"base64-content","password":"keystorepass","type":"JKS"}(must be a single-line JSON string) - Click "OK"
Managing Credentials¶
Viewing Credentials¶
Using Control Panel:
- Open Control Panel → User Accounts → Credential Manager
- Click "Windows Credentials"
- Look for credentials starting with
galasa.credentials.
Using PowerShell:
Updating Credentials¶
Using Control Panel:
- Open Credential Manager
- Find the credential under "Windows Credentials"
- Click the arrow to expand
- Click "Edit"
- Update the values
- Click "Save"
Using PowerShell:
# Update by deleting and re-adding
cmdkey /delete:"galasa.credentials.MYCRED"
cmdkey /generic:"galasa.credentials.MYCRED" /user:"newuser" /pass:"newpass"
Deleting Credentials¶
Using Control Panel:
- Open Credential Manager
- Find the credential under "Windows Credentials"
- Click the arrow to expand
- Click "Remove"
- Confirm deletion
Using PowerShell:
Security Considerations¶
Credential Protection¶
Windows Credential Manager stores credentials encrypted using the Windows Data Protection API (DPAPI):
- Credentials are encrypted with your Windows user account
- Only your user account can decrypt and access the credentials
- Credentials are protected even if someone gains physical access to your hard drive
Best Practices¶
- Regular audits: Periodically review stored credentials in Credential Manager
- Principle of least privilege: Only store credentials that are actually needed
- Shared systems: Be cautious when using shared Windows systems - credentials are user-specific
- Backup considerations: Credentials are tied to your user profile and Windows installation
Troubleshooting¶
"Credentials not found" Error¶
Cause: The credential doesn't exist in Credential Manager or the target name is incorrect.
Solution:
- Verify the credential exists:
- Check the target name format: must be
galasa.credentials.{ID} - Ensure the credential is stored as a "Generic Credential" (not "Windows Credential" or "Certificate-Based Credential")
"Access Denied" Error¶
Cause: Insufficient permissions to access Credential Manager.
Solution:
- Ensure you're running as the same user who created the credential
- Check Windows user account permissions
- Try running your application as administrator (not recommended for regular use)
Invalid JSON Error (KeyStore credentials)¶
Cause: The JSON in the password field is malformed or missing required fields.
Solution:
- Validate your JSON using a JSON validator
- Ensure all required fields are present:
keystore,password,type - Verify the keystore content is properly base64-encoded
- Ensure the JSON is a single line with no line breaks
- Check for special characters that might need escaping in PowerShell
KeyStore Loading Error¶
Cause: The base64-encoded keystore content is invalid or corrupted.
Solution:
- Re-encode the keystore file:
- Verify the keystore is valid:
- Ensure the keystore password in the JSON matches the actual keystore password
Credential Manager Not Available¶
Cause: Credential Manager service is not running or disabled.
Solution:
- Open Services (services.msc)
- Find "Credential Manager" service
- Ensure it's set to "Automatic" and is running
- If stopped, start the service