Merge branch '3.1.x'

Closes gh-38226
This commit is contained in:
Moritz Halbritter
2023-11-06 10:27:50 +01:00
3 changed files with 23 additions and 24 deletions

View File

@@ -163,22 +163,20 @@ public class Neo4jAutoConfiguration {
private TrustStrategy createTrustStrategy(Neo4jProperties.Security securityProperties, String propertyName,
Security.TrustStrategy strategy) {
switch (strategy) {
case TRUST_ALL_CERTIFICATES:
return TrustStrategy.trustAllCertificates();
case TRUST_SYSTEM_CA_SIGNED_CERTIFICATES:
return TrustStrategy.trustSystemCertificates();
case TRUST_CUSTOM_CA_SIGNED_CERTIFICATES:
return switch (strategy) {
case TRUST_ALL_CERTIFICATES -> TrustStrategy.trustAllCertificates();
case TRUST_SYSTEM_CA_SIGNED_CERTIFICATES -> TrustStrategy.trustSystemCertificates();
case TRUST_CUSTOM_CA_SIGNED_CERTIFICATES -> {
File certFile = securityProperties.getCertFile();
if (certFile == null || !certFile.isFile()) {
throw new InvalidConfigurationPropertyValueException(propertyName, strategy.name(),
"Configured trust strategy requires a certificate file.");
}
return TrustStrategy.trustCustomCertificateSignedBy(certFile);
default:
throw new InvalidConfigurationPropertyValueException(propertyName, strategy.name(),
"Unknown strategy.");
}
yield TrustStrategy.trustCustomCertificateSignedBy(certFile);
}
default -> throw new InvalidConfigurationPropertyValueException(propertyName, strategy.name(),
"Unknown strategy.");
};
}
/**