Skip to content

[4.12.x]Support for HSM-backed Keystores for Signing and Encryption#4518

Open
RivinduM wants to merge 2 commits into
wso2:4.12.xfrom
RivinduM:4.12.x
Open

[4.12.x]Support for HSM-backed Keystores for Signing and Encryption#4518
RivinduM wants to merge 2 commits into
wso2:4.12.xfrom
RivinduM:4.12.x

Conversation

@RivinduM
Copy link
Copy Markdown

Purpose

This pr adds support to configure and load a HSM keystore via the PKCS11 API.

deployment.toml configuration

[keystore.hsm]
enabled = true
pin = "hsm_pin"
alias = "hsm_key_alias"
provider_configuration = "pkcs11.cfg"

Related Issue

wso2/product-is#26706

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 25, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

public KeyStore getHSMKeyStore() throws
KeyStoreException, CertificateException, IOException, NoSuchAlgorithmException, CarbonException {

if (tenantId == MultitenantConstants.SUPER_TENANT_ID) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 1

Suggested change
if (tenantId == MultitenantConstants.SUPER_TENANT_ID) {
if (tenantId == MultitenantConstants.SUPER_TENANT_ID) {
log.info("Loading HSM key store for super tenant.");

Comment on lines +611 to +614
KeyStore ks = KeyStore.getInstance(PKCS11, pkcs11);
ks.load(null, this.getServerConfigService()
.getFirstProperty(RegistryResources.SecurityManagement.SERVER_HSM_KEYSTORE_PASSWORD).toCharArray());
log.info("HSM keystore loaded successfully.");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 2

Suggested change
KeyStore ks = KeyStore.getInstance(PKCS11, pkcs11);
ks.load(null, this.getServerConfigService()
.getFirstProperty(RegistryResources.SecurityManagement.SERVER_HSM_KEYSTORE_PASSWORD).toCharArray());
log.info("HSM keystore loaded successfully.");
KeyStore ks = KeyStore.getInstance(PKCS11, pkcs11);
ks.load(null, this.getServerConfigService()
.getFirstProperty(RegistryResources.SecurityManagement.SERVER_HSM_KEYSTORE_PASSWORD).toCharArray());
log.info("HSM keystore loaded successfully with provider: " + pkcs11.getName());

Copy link
Copy Markdown

@wso2-engineering wso2-engineering Bot left a comment

Choose a reason for hiding this comment

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

AI Agent Log Improvement Checklist

⚠️ Warning: AI-Generated Review Comments

  • The log-related comments and suggestions in this review were generated by an AI tool to assist with identifying potential improvements. Purpose of reviewing the code for log improvements is to improve the troubleshooting capabilities of our products.
  • Please make sure to manually review and validate all suggestions before applying any changes. Not every code suggestion would make sense or add value to our purpose. Therefore, you have the freedom to decide which of the suggestions are helpful.

✅ Before merging this pull request:

  • Review all AI-generated comments for accuracy and relevance.
  • Complete and verify the table below. We need your feedback to measure the accuracy of these suggestions and the value they add. If you are rejecting a certain code suggestion, please mention the reason briefly in the suggestion for us to capture it.
Comment Accepted (Y/N) Reason
#### Log Improvement Suggestion No: 1
#### Log Improvement Suggestion No: 2

# Conflicts:
#	core/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/util/KeyStoreManager.java
@jenkins-is-staging
Copy link
Copy Markdown

PR builder started
Link: https://github.com/wso2/product-is/actions/runs/22992707911

@jenkins-is-staging
Copy link
Copy Markdown

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/22992707911
Status: success

Copy link
Copy Markdown

@jenkins-is-staging jenkins-is-staging left a comment

Choose a reason for hiding this comment

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

Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/22992707911

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.

3 participants