-
Notifications
You must be signed in to change notification settings - Fork 41.7k
Add support for LDAPS testing #48315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,9 +16,12 @@ | |
|
|
||
| package org.springframework.boot.ldap.autoconfigure.embedded; | ||
|
|
||
| import java.security.NoSuchAlgorithmException; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| import javax.net.ssl.SSLContext; | ||
|
|
||
| import org.jspecify.annotations.Nullable; | ||
|
|
||
| import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
|
@@ -62,6 +65,11 @@ public class EmbeddedLdapProperties { | |
| */ | ||
| private final Validation validation = new Validation(); | ||
|
|
||
| /** | ||
| * SSL configuration. | ||
| */ | ||
| private final Ssl ssl = new Ssl(); | ||
wilkinsona marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| public int getPort() { | ||
| return this.port; | ||
| } | ||
|
|
@@ -98,6 +106,10 @@ public Validation getValidation() { | |
| return this.validation; | ||
| } | ||
|
|
||
| public Ssl getSsl() { | ||
| return this.ssl; | ||
| } | ||
|
|
||
| public static class Credential { | ||
|
|
||
| /** | ||
|
|
@@ -132,6 +144,174 @@ boolean isAvailable() { | |
|
|
||
| } | ||
|
|
||
| public static class Ssl { | ||
|
|
||
| private static final String SUN_X509 = "SunX509"; | ||
|
|
||
| private static final String DEFAULT_PROTOCOL; | ||
|
|
||
| static { | ||
| String protocol = "TLSv1.1"; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, with v3 I meant 1.3.
Which I would argue, security-wise, why not v1.3 if available? 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. |
||
| try { | ||
| String[] protocols = SSLContext.getDefault().getSupportedSSLParameters().getProtocols(); | ||
| for (String prot : protocols) { | ||
| if ("TLSv1.2".equals(prot)) { | ||
| protocol = "TLSv1.2"; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| catch (NoSuchAlgorithmException ex) { | ||
| // nothing | ||
| } | ||
| DEFAULT_PROTOCOL = protocol; | ||
| } | ||
|
|
||
| /** | ||
| * Whether to enable SSL support. | ||
| */ | ||
| private Boolean enabled = false; | ||
|
|
||
| /** | ||
| * SSL bundle name. | ||
| */ | ||
| private @Nullable String bundle; | ||
|
|
||
| /** | ||
| * Path to the key store that holds the SSL certificate. | ||
| */ | ||
| private @Nullable String keyStore; | ||
|
|
||
| /** | ||
| * Key store type. | ||
| */ | ||
| private String keyStoreType = "PKCS12"; | ||
|
|
||
| /** | ||
| * Password used to access the key store. | ||
| */ | ||
| private @Nullable String keyStorePassword; | ||
|
|
||
| /** | ||
| * Key store algorithm. | ||
| */ | ||
| private String keyStoreAlgorithm = SUN_X509; | ||
|
|
||
| /** | ||
| * Trust store that holds SSL certificates. | ||
| */ | ||
| private @Nullable String trustStore; | ||
|
|
||
| /** | ||
| * Trust store type. | ||
| */ | ||
| private String trustStoreType = "JKS"; | ||
|
|
||
| /** | ||
| * Password used to access the trust store. | ||
| */ | ||
| private @Nullable String trustStorePassword; | ||
|
|
||
| /** | ||
| * Trust store algorithm. | ||
| */ | ||
| private String trustStoreAlgorithm = SUN_X509; | ||
|
|
||
| /** | ||
| * SSL algorithm to use. | ||
| */ | ||
| private String algorithm = DEFAULT_PROTOCOL; | ||
|
|
||
| public Boolean isEnabled() { | ||
| return this.enabled; | ||
| } | ||
|
|
||
| public void setEnabled(Boolean enabled) { | ||
| this.enabled = enabled; | ||
| } | ||
|
|
||
| public @Nullable String getBundle() { | ||
| return this.bundle; | ||
| } | ||
|
|
||
| public void setBundle(@Nullable String bundle) { | ||
| this.bundle = bundle; | ||
| } | ||
|
|
||
| public @Nullable String getKeyStore() { | ||
| return this.keyStore; | ||
| } | ||
|
|
||
| public void setKeyStore(@Nullable String keyStore) { | ||
| this.keyStore = keyStore; | ||
| } | ||
|
|
||
| public String getKeyStoreType() { | ||
| return this.keyStoreType; | ||
| } | ||
|
|
||
| public void setKeyStoreType(String keyStoreType) { | ||
| this.keyStoreType = keyStoreType; | ||
| } | ||
|
|
||
| public @Nullable String getKeyStorePassword() { | ||
| return this.keyStorePassword; | ||
| } | ||
|
|
||
| public void setKeyStorePassword(@Nullable String keyStorePassword) { | ||
| this.keyStorePassword = keyStorePassword; | ||
| } | ||
|
|
||
| public String getKeyStoreAlgorithm() { | ||
| return this.keyStoreAlgorithm; | ||
| } | ||
|
|
||
| public void setKeyStoreAlgorithm(String keyStoreAlgorithm) { | ||
| this.keyStoreAlgorithm = keyStoreAlgorithm; | ||
| } | ||
|
|
||
| public @Nullable String getTrustStore() { | ||
| return this.trustStore; | ||
| } | ||
|
|
||
| public void setTrustStore(@Nullable String trustStore) { | ||
| this.trustStore = trustStore; | ||
| } | ||
|
|
||
| public String getTrustStoreType() { | ||
| return this.trustStoreType; | ||
| } | ||
|
|
||
| public void setTrustStoreType(String trustStoreType) { | ||
| this.trustStoreType = trustStoreType; | ||
| } | ||
|
|
||
| public @Nullable String getTrustStorePassword() { | ||
| return this.trustStorePassword; | ||
| } | ||
|
|
||
| public void setTrustStorePassword(@Nullable String trustStorePassword) { | ||
| this.trustStorePassword = trustStorePassword; | ||
| } | ||
|
|
||
| public String getTrustStoreAlgorithm() { | ||
| return this.trustStoreAlgorithm; | ||
| } | ||
|
|
||
| public void setTrustStoreAlgorithm(String trustStoreAlgorithm) { | ||
| this.trustStoreAlgorithm = trustStoreAlgorithm; | ||
| } | ||
|
|
||
| public String getAlgorithm() { | ||
| return this.algorithm; | ||
| } | ||
|
|
||
| public void setAlgorithm(String sslAlgorithm) { | ||
| this.algorithm = sslAlgorithm; | ||
| } | ||
|
|
||
| } | ||
|
|
||
| public static class Validation { | ||
|
|
||
| /** | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.