Skip to content

Conversation

@CatiaCorreia
Copy link

Add to EmbeddedLdapProperties:
-boolean ldaps
-String sslBundleName
Create setLdapsListener method to create and set the LDAPS listener for the server. Add test for new embedded LDAP setup.
Issue#48060

Signed-off-by: CatiaCorreia [email protected]

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 27, 2025
Copy link
Member

@snicoll snicoll left a comment

Choose a reason for hiding this comment

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

Can you please review the proposal. I've added a couple of comments for a start.

}
}

@ConditionalOnBean(SslBundles.class)
Copy link
Member

Choose a reason for hiding this comment

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

I don't know what this is but you can't add a condition on a private method. What's that supposed to do?

}

@Test
void testLdapsVersion() {
Copy link
Member

Choose a reason for hiding this comment

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

That doesn't test the SSL bundles, nor the binding. It doesn't work atm anyway (see previous comment).

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Nov 27, 2025
Copy link
Member

@wilkinsona wilkinsona left a comment

Choose a reason for hiding this comment

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

Thanks very much for the PR, @CatiaCorreia. I've left a few comments for your consideration.

Comment on lines 60 to 68
/**
* Listener type.
*/
private boolean ldaps;

/**
* Embedded LDAPS client SSL bundle name.
*/
@Nullable private String sslBundleName;
Copy link
Member

Choose a reason for hiding this comment

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

For consistency with other SSL configuration in Spring Boot, the properties should be grouped together in an SSL inner-class. That class should have an enabled property, a bundle property as well as properties for configuring things without using an SSL bundle. org.springframework.boot.amqp.autoconfigure.RabbitProperties.Ssl is a client-side example of that sort of arrangement.

Copy link

Choose a reason for hiding this comment

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

Hi @wilkinsona.
What's the plan of the Spring Boot team regarding such double configuration possibilities?

It is my understanding (e.g.: https://spring.io/blog/2023/06/07/securing-spring-boot-applications-with-ssl#securing-embedded-web-servers), which can easily be wrong, that using SSL bundles is now the preferred way and that the "old" way of specifying single properties should not be used anymore.
If it's indeed the case, does it really make sense to introduce something which is potentially already deprecated?

}

@Bean
InMemoryDirectoryServer directoryServer(ApplicationContext applicationContext) throws LDAPException {
Copy link
Member

Choose a reason for hiding this comment

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

SslBundles should be injected here using ObjectProvider<SslBundles> sslBundles. You can then use getIfAvailable() to get the bean if it exists or null if it does not.

}
}

@ConditionalOnBean(SslBundles.class)
Copy link
Member

@wilkinsona wilkinsona Nov 27, 2025

Choose a reason for hiding this comment

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

This won't have any effect here as conditions only work on classes and @Bean methods. It can be removed if you inject SslBundles as suggested above.

@CatiaCorreia
Copy link
Author

Thank you for all the feedback. I will start working on the changes right away.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Nov 28, 2025
@wilkinsona wilkinsona added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Nov 30, 2025
@CatiaCorreia
Copy link
Author

I'm writing this message to give a status report. I have implemented the changes discussed above and have tried testing them. I believe I have successfully implemented the creation of the server with SSL without SslBundles. However when it comes to the SslBundles I haven't been able to get a successful test even thought I can't find a problem. There seems to be a problem when the client tries to get a connection to the server (LDAPException code 91). I have committed the changes to a separate branch as I was unsure if I should commit them to this one directly. The branch is found here: https://github.com/CatiaCorreia/spring-boot/tree/gh%2348060-Troubleshooting
At this stage I am trying to ascertain the motive for this error.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Dec 2, 2025
@CatiaCorreia
Copy link
Author

As I haven't been able to figure out the problem I would like to know if its possible to receive some kind of advice or suggestion. If it isn't possible I will have to move on and tackle another issue.
Thank you for your time.

@snicoll snicoll self-requested a review December 5, 2025 20:34
this.embeddedProperties.getPort(), serverSocketFactory, clientSocketFactory));
}
else {
throw new LDAPException(ResultCode.PARAM_ERROR, "SslBundleName property not specified");
Copy link

Choose a reason for hiding this comment

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

I would argue here that this is not really the right exception type. Here you didn't use nor setup LDAP at all yet, so it's misleading to say that there is an error with LDAP itself.
It's purely a configuration issue.

@wilkinsona isn't there maybe some Spring(Boot) config-specific exception which may be used here?

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for trying to help, @cdprete, but things have moved on with https://github.com/CatiaCorreia/spring-boot/tree/gh%2348060-Troubleshooting containing the latest code.

Copy link

@cdprete cdprete Dec 15, 2025

Choose a reason for hiding this comment

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

Thanks for pointing it out @wilkinsona.

@wilkinsona wilkinsona self-assigned this Dec 15, 2025
@wilkinsona
Copy link
Member

Thanks for the latest updates, @CatiaCorreia.

As I haven't been able to figure out the problem I would like to know if its possible to receive some kind of advice or suggestion.

The SSL bundle test that was failing was trying to use a different protocol when creating the SSL context (TLS rather than TLSv1.2). testServerWithSslBundle passes when I add this line to it:

propertyValues.add("spring.ssl.bundle.jks.test.protocol=TLSv1.2");

Would you like to force-push your gh#48060 branch with the changes in gh#48060-Troubleshooting and this additional line? That should get us into a position where we can merge this once we've created our 4.0.x branch and main is producing 4.1.0 snapshots.

@wilkinsona wilkinsona added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Dec 15, 2025
@CatiaCorreia
Copy link
Author

Thank you very much for the help @wilkinsona. I'll make the changes as soon as I can and do the force push as requested.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Dec 15, 2025
Add to EmbeddedLdapProperties:
-boolean ldaps
-String sslBundleName
Create setLdapsListener method to create and set the LDAPS listener for the server.
Add test for new embedded LDAP setup.
Issue#48060

Signed-off-by: CatiaCorreia <[email protected]>
Setup autoconfiguration of LDAP listener with ssl.
Add tests using ssl.
Issue#48060

Signed-off-by: CatiaCorreia [email protected]
Signed-off-by: CatiaCorreia <[email protected]>
private static final String DEFAULT_PROTOCOL;

static {
String protocol = "TLSv1.1";
Copy link

Choose a reason for hiding this comment

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

Security-wise, TLS v3 should be the default and not v1 which is not really supported anymore.

Copy link
Member

Choose a reason for hiding this comment

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

The default will be TLSv1.2 as long as the JDK supports it (see the try block below). AFAIK, there's no TLS v3. There is, however, TLSv1.3.

Copy link

@cdprete cdprete Dec 15, 2025

Choose a reason for hiding this comment

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

Yes, with v3 I meant 1.3.

The default will be TLSv1.2 as long as the JDK supports it

Which I would argue, security-wise, why not v1.3 if available?
Personally, I think that the default should be the most secure supported option and the user must take an explicit risk by explicitly configure the application to something lower if he/she really wants to.

Also, although it would be weird, getProtocols() can actually return null which would lead to a NPE when the loop gets initiated. Dunno if you want to handle/check such weird case to begin with.

Copy link
Author

Choose a reason for hiding this comment

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

I chose to use the TLSv1.2 by default to be consistent with what is present in other modules of spring boot. @wilkinsona should I keep the consistency or would it be better to use the TLSv1.3? Regarding the possibility of getProtocols() returning null I will make the changes to test for it.

Copy link

@cdprete cdprete Dec 16, 2025

Choose a reason for hiding this comment

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

I chose to use the TLSv1.2 by default to be consistent with what is present in other modules of spring boot.

I see.
Fine for me then.

cdprete referenced this pull request in CatiaCorreia/spring-boot Dec 15, 2025
@wilkinsona wilkinsona added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Dec 15, 2025
@wilkinsona wilkinsona added this to the 4.1.x milestone Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants