Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@rmartinc
Copy link
Contributor

@rmartinc rmartinc commented Jul 1, 2024

Closes #30880
Closes #29755

Adding all the algorithms to the java-keystore key provider. Besides the passwords (store and key) can also be configured through the vault. This way all the realm keys can be externalized to an external keystore file. There are some discrepancies between what keys can be stored in the different store types and in the different security providers:

  • JKS store type cannot store secret keys (AES or HMAC) in any provider.
  • PKCS12 allows to store all key types in non-fips mode but BCFIPS does not allow to store secret keys either (so in both fips modes this store cannot contain secret keys).
  • BCFKS is weird in the BC provider (non-fips) and, for example, HMAC keys do not work (bug?) although they work on BCFIPS (fips modes).

I have discovered that EdDSA keys do not work in fips modes at all because BCFIPS does not implement for them the standard JDK 15+ interfaces that keycloak uses to manage them (EdEC, EdECPrivateKey and EdECPublicKey). This is a different story. Probably we need an issue even if we just document this fact.

So in general the standard PKCS12 format seems to be the best for non-fips and BCFKS for fips modes.

Little changes in how the JavaKeystoreKeyProvider loads the keys. The public key for asymmetric keys is loaded using the certificate as it should always be there.

Tests added with the limitations in the store/providers commented above.

Copy link
Contributor

@jonkoops jonkoops left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff!

Copy link
Contributor

@mposolda mposolda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rmartinc @jonkoops Thanks for this and for the review!

@mposolda mposolda merged commit 096e335 into keycloak:main Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add vault support to JavaKeystoreKeyProvider Support AES and HMAC Key-Imports for the JavaKeystoreKeyProvider

3 participants