Hakky54 commented on a change in pull request #626:
URL: https://github.com/apache/james-project/pull/626#discussion_r698006088
##########
File path:
server/protocols/protocols-library/src/main/java/org/apache/james/protocols/lib/netty/AbstractConfigurableAsyncServer.java
##########
@@ -390,18 +400,33 @@ protected Encryption getEncryption() {
protected void buildSSLContext() throws Exception {
if (useStartTLS || useSSL) {
FileInputStream fis = null;
+ // Initialize the SSLContext to work with our key managers.
+ SSLContext context = SSLContext.getInstance("TLS");
Review comment:
You might be able to simplify the code logic here by delegating
everything to the SSLFactory, see here for the code snippet:
```
SSLFactory.Builder sslFactoryBuilder = SSLFactory.builder()
.withSslContextAlgorithm("TLS");
if (keyStore != null) {
sslFactoryBuilder.withIdentityMaterial(
fileSystem.getFile(keystore).toPath(),
secret.toCharArray(),
Optional.of(secret)
.orElse("")
.toCharArray());
} else {
X509ExtendedKeyManager keyManager = PemUtils.loadIdentityMaterial(
fileSystem.getResource(certificates),
fileSystem.getResource(privateKey),
Optional.ofNullable(secret)
.map(String::toCharArray)
.orElse(null));
sslFactoryBuilder.withIdentityMaterial(keyManager);
}
SSLContext context = sslFactoryBuilder.build()
.getSslContext();
if (useStartTLS) {
encryption = Encryption.createStartTls(context, enabledCipherSuites);
} else {
encryption = Encryption.createTls(context, enabledCipherSuites);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]