Skip to content

Conversation

@rudraneel-chakraborty
Copy link
Contributor

@rudraneel-chakraborty rudraneel-chakraborty commented Nov 3, 2025

What is the purpose of this change?

implement asks of https://sol-jira.atlassian.net/browse/DATAGO-116001

How was this change implemented?

Java

How was this change tested?

IT manually

Is there anything the reviewers should focus on/be aware of?

...

Comment on lines 149 to 153
boolean isCustomCACertConfigured() {
String customCaCertsPresent = System.getenv("CUSTOM_CA_CERTS_PRESENT");

return ("1".equals(customCaCertsPresent));
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Package private to aid in testing

Comment on lines 155 to 172
void setDefaultTrustStore(Properties properties) {
String javaHome = System.getProperty("java.home");
if (StringUtils.isBlank(javaHome)) {
log.warn("java.home system property is not set. Cannot configure default truststore for JCSMP.");
return;
}
Path defaultTrustStorePath = Paths.get(javaHome, "lib", "security", "cacerts");
File trustStoreFile = defaultTrustStorePath.toFile();

if (!trustStoreFile.exists() || !trustStoreFile.canRead()) {
log.warn("Default truststore not found or not readable at: {}. JCSMP connection may fail.", defaultTrustStorePath);
return;
}

log.debug("Custom CA certificates present. Explicitly configuring EVMR connection to use default truststore: {}", defaultTrustStorePath);
properties.setProperty(SolaceProperties.TransportLayerSecurityProperties.TRUST_STORE_PATH, defaultTrustStorePath.toString());
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

package private to help in testing

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR configures the JCSMP (Java Client Solace Messaging Protocol) to use the default JDK truststore when connecting to Event Portal, specifically when custom CA certificates are present in the environment.

Key Changes:

  • Added logic to detect custom CA certificates via environment variable and configure JCSMP truststore accordingly
  • Implemented truststore path validation and file existence checks
  • Added unit tests to verify the truststore configuration behavior

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
VMRProperties.java Added methods to check for custom CA certs and configure default JDK truststore path for JCSMP connections
VMRPropertiesTests.java Added tests verifying truststore configuration is called/skipped based on custom CA cert presence; fixed package declaration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

properties.setProperty(SolaceProperties.AuthenticationProperties.SCHEME_BASIC_PASSWORD, password);
properties.setProperty(SolaceProperties.ClientProperties.NAME, clientName);

//We will always use the default jks truststore for connecting to the EVMR
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

The comment states 'We will always use the default jks truststore' but the implementation only configures it when CUSTOM_CA_CERTS_PRESENT=1. Update the comment to accurately reflect the conditional behavior.

Suggested change
//We will always use the default jks truststore for connecting to the EVMR
// Explicitly configure the default JKS truststore for connecting to the EVMR only when custom CA certificates are present

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree with this comment 👍

Comment on lines 149 to 153
boolean isCustomCACertConfigured() {
String customCaCertsPresent = System.getenv("CUSTOM_CA_CERTS_PRESENT");

return ("1".equals(customCaCertsPresent));
}
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

The method name isCustomCACertConfigured is misleading - it checks whether custom CA certs are present, not whether they are configured. Consider renaming to hasCustomCACerts or isCustomCACertPresent to better reflect what it checks.

Copilot uses AI. Check for mistakes.
@Test
@SneakyThrows
void testSetDefaultTrustStoreCalledWhenCustomCaCertsPresent() {
// Spy on vmrProperties to mock getCustomCaCertsPresentEnv and verify setDefaultTrustStore is called
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

The comment references a non-existent method getCustomCaCertsPresentEnv. It should reference isCustomCACertConfigured instead to match the actual method being mocked.

Copilot uses AI. Check for mistakes.
@Test
@SneakyThrows
void testSetDefaultTrustStoreNotCalledWhenCustomCaCertsNotPresent() {
// Spy on vmrProperties to mock getCustomCaCertsPresentEnv and verify setDefaultTrustStore is NOT called
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

The comment references a non-existent method getCustomCaCertsPresentEnv. It should reference isCustomCACertConfigured instead to match the actual method being mocked.

Suggested change
// Spy on vmrProperties to mock getCustomCaCertsPresentEnv and verify setDefaultTrustStore is NOT called
// Spy on vmrProperties to mock isCustomCACertConfigured and verify setDefaultTrustStore is NOT called

Copilot uses AI. Check for mistakes.
@moodiRealist moodiRealist changed the title DATAGO-116002: event-management-agent: Configure JCSMP to use default JDK truststore for Event Portal connections DATAGO-116001: event-management-agent: Configure JCSMP to use default JDK truststore for Event Portal connections Nov 5, 2025
Copy link
Collaborator

@moodiRealist moodiRealist left a comment

Choose a reason for hiding this comment

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

PR looks good, but we shouldn't merge it until changes to applicatoin.yml file are reverted.

properties.setProperty(SolaceProperties.AuthenticationProperties.SCHEME_BASIC_PASSWORD, password);
properties.setProperty(SolaceProperties.ClientProperties.NAME, clientName);

//We will always use the default jks truststore for connecting to the EVMR
Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree with this comment 👍

@rudraneel-chakraborty rudraneel-chakraborty marked this pull request as ready for review November 5, 2025 16:13
@Mock
private ScanStatusPublisher scanStatusPublisher;

@Mock
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use @MockitoBean in here as well?

@sonarqube-solacecloud
Copy link

Quality Gate failed Quality Gate failed

Failed conditions
2 New issues
25.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE SonarQube for IDE

@SolaceProducts SolaceProducts deleted a comment from moodiRealist Nov 5, 2025
@rudraneel-chakraborty rudraneel-chakraborty merged commit 95a8d10 into main Nov 6, 2025
5 of 6 checks passed
@rudraneel-chakraborty rudraneel-chakraborty deleted the DATAGO-116001-custom-cert-ema-work branch November 6, 2025 18:51
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