Add property to enable key verification on PEM SSL bundles

Closes gh-37727
This commit is contained in:
Moritz Halbritter
2023-10-04 15:11:47 +02:00
parent 85aeedeace
commit 0a16ec17e9
13 changed files with 494 additions and 21 deletions

View File

@@ -23,6 +23,7 @@ import org.springframework.boot.ssl.pem.PemSslStoreBundle;
*
* @author Scott Frederick
* @author Phillip Webb
* @author Moritz Halbritter
* @since 3.1.0
* @see PemSslStoreBundle
*/
@@ -38,6 +39,11 @@ public class PemSslBundleProperties extends SslBundleProperties {
*/
private final Store truststore = new Store();
/**
* Whether to verify that the private key matches the public key.
*/
private boolean verifyKeys;
public Store getKeystore() {
return this.keystore;
}
@@ -46,6 +52,14 @@ public class PemSslBundleProperties extends SslBundleProperties {
return this.truststore;
}
public boolean isVerifyKeys() {
return this.verifyKeys;
}
public void setVerifyKeys(boolean verifyKeys) {
this.verifyKeys = verifyKeys;
}
/**
* Store properties.
*/

View File

@@ -109,7 +109,8 @@ public final class PropertiesSslBundle implements SslBundle {
private static SslStoreBundle asSslStoreBundle(PemSslBundleProperties properties) {
PemSslStoreDetails keyStoreDetails = asStoreDetails(properties.getKeystore());
PemSslStoreDetails trustStoreDetails = asStoreDetails(properties.getTruststore());
return new PemSslStoreBundle(keyStoreDetails, trustStoreDetails, properties.getKey().getAlias());
return new PemSslStoreBundle(keyStoreDetails, trustStoreDetails, properties.getKey().getAlias(), null,
properties.isVerifyKeys());
}
private static PemSslStoreDetails asStoreDetails(PemSslBundleProperties.Store properties) {