Skip to content

Commit

Permalink
Merge pull request #92 from HubSpot/js-configurable-ssl-protocols
Browse files Browse the repository at this point in the history
allow ssl protocols to be configurable per imap connection
  • Loading branch information
jaredstehler authored Jan 28, 2025
2 parents a88c08e + 931f48a commit e078517
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/main/java/com/hubspot/imap/ImapClientConfigurationIF.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.hubspot.imap.utils.ConfigDefaults;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import javax.net.ssl.TrustManagerFactory;
import org.immutables.value.Value.Default;
import org.immutables.value.Value.Derived;
Expand Down Expand Up @@ -36,6 +37,11 @@ default boolean useSsl() {
return true;
}

@Default
default Set<String> sslProtocols() {
return Set.of();
}

@Default
default int noopKeepAliveIntervalSec() {
return -1;
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/com/hubspot/imap/ImapClientFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,15 @@ private SslContext getSslContext(ImapClientConfiguration clientConfiguration) {
return sslContext;
}
try {
return SslContextBuilder
SslContextBuilder sslContextBuilder = SslContextBuilder
.forClient()
.trustManager(clientConfiguration.trustManagerFactory().get())
.build();
.trustManager(clientConfiguration.trustManagerFactory().get());

if (!clientConfiguration.sslProtocols().isEmpty()) {
sslContextBuilder.protocols(clientConfiguration.sslProtocols());
}

return sslContextBuilder.build();
} catch (SSLException e) {
throw new RuntimeException(e);
}
Expand Down

0 comments on commit e078517

Please sign in to comment.