Skip to content

Commit

Permalink
Clean up TLS Socket Factory in key management service
Browse files Browse the repository at this point in the history
  • Loading branch information
jyemin committed May 22, 2020
1 parent 868821a commit 9810ce4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ public void close() {
commandMarker.close();
}
keyRetriever.close();
keyManagementService.close();
}

private void executeStateMachine(final MongoCryptContext cryptContext, final String databaseName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,24 @@

class KeyManagementService {
private final int defaultPort;
private final TlsChannelStreamFactoryFactory tlsChannelStreamFactoryFactory;
private final StreamFactory streamFactory;

KeyManagementService(final SSLContext sslContext, final int defaultPort, final int timeoutMillis) {
this.defaultPort = defaultPort;
this.streamFactory = new TlsChannelStreamFactoryFactory().create(SocketSettings.builder()
this.tlsChannelStreamFactoryFactory = new TlsChannelStreamFactoryFactory();
this.streamFactory = tlsChannelStreamFactoryFactory.create(SocketSettings.builder()
.connectTimeout(timeoutMillis, TimeUnit.MILLISECONDS)
.readTimeout(timeoutMillis, TimeUnit.MILLISECONDS)
.build(),
SslSettings.builder().enabled(true).context(sslContext).build());
}


public void close() {
tlsChannelStreamFactoryFactory.close();
}

void decryptKey(final MongoKeyDecryptor keyDecryptor, final SingleResultCallback<Void> callback) {
streamOpen(keyDecryptor, callback);
}
Expand Down

0 comments on commit 9810ce4

Please sign in to comment.