Skip to content

REF-6: Resolve keystore alias case-insensitively (issue #73)#85

Open
thomasnymand wants to merge 1 commit into
masterfrom
feature/REF-6-keystore-alias-case-insensitive
Open

REF-6: Resolve keystore alias case-insensitively (issue #73)#85
thomasnymand wants to merge 1 commit into
masterfrom
feature/REF-6-keystore-alias-case-insensitive

Conversation

@thomasnymand

Copy link
Copy Markdown
Collaborator

Fixes #73

Summary

Configuring oiosaml.servlet.keystore.alias with any casing other than all-lowercase failed with a misleading "incorrect keystore password" error.

Root cause: Java's PKCS12 KeyStore lowercases aliases on load, so in CredentialService.getBasicX509Credential() the key-password map was keyed by the keystore's (lowercased) alias, while OpenSAML's KeyStoreCredentialResolver looks the password up by the configured alias verbatim. A mixed-case alias therefore resolved no password, the private key couldn't be decrypted, and the failure surfaced as a wrong-password error.

Fix: key the password map by the configured alias instead of ks.aliases().nextElement(). PKCS12 key lookup is already case-insensitive, so alias resolution is now fully case-insensitive — no configuration or documentation workaround needed.

Test

Adds CredentialServiceTest with a new keystore mixedcase-alias.p12 (key entry created as TestKeyAlias, which PKCS12 stores as testkeyalias). The test configures the alias in a different case and asserts the credential resolves.

Verified red → green: the test errors on the previous code (Malformed configuration in 'oiosaml.servlet.keystore') and passes with the fix. Full suite: Tests run: 108, Failures: 0, Errors: 0.

Notes

  • Branched after REF-5 merged to master, so this includes the CI workflow — checks will run on this PR.

🤖 Generated with Claude Code

Configuring oiosaml.servlet.keystore.alias with any casing other than
all-lowercase failed with a misleading "incorrect keystore password"
error.

Java's PKCS12 KeyStore lowercases aliases on load, so the key-password
map was keyed by the lowercased alias while OpenSAML's
KeyStoreCredentialResolver looked the password up by the configured
alias verbatim. A mixed-case alias therefore resolved no password and
the private key could not be decrypted.

Key the password map by the configured alias instead; PKCS12 key lookup
is already case-insensitive, so alias resolution is now fully
case-insensitive. Add CredentialServiceTest with a keystore whose alias
is configured in a different case than stored.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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

Successfully merging this pull request may close these issues.

Missing documentation about correct casing of oiosaml.servlet.keystore.alias

1 participant