Skip to content

Commit ecc87c4

Browse files
committed
Adapt to SSLHelper rework
1 parent f45ecf7 commit ecc87c4

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

vertx-mssql-client/src/main/java/io/vertx/mssqlclient/impl/MSSQLConnectionFactory.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
import io.vertx.core.Promise;
1717
import io.vertx.core.internal.ContextInternal;
1818
import io.vertx.core.internal.VertxInternal;
19+
import io.vertx.core.internal.tls.SslContextManager;
1920
import io.vertx.core.net.HostAndPort;
2021
import io.vertx.core.net.NetSocket;
2122
import io.vertx.core.net.SocketAddress;
2223
import io.vertx.core.internal.net.NetSocketInternal;
23-
import io.vertx.core.net.impl.SSLHelper;
24+
import io.vertx.core.net.impl.NetServerImpl;
2425
import io.vertx.core.spi.metrics.ClientMetrics;
2526
import io.vertx.core.spi.metrics.VertxMetrics;
2627
import io.vertx.mssqlclient.MSSQLConnectOptions;
@@ -34,11 +35,11 @@
3435

3536
public class MSSQLConnectionFactory extends ConnectionFactoryBase<MSSQLConnectOptions> {
3637

37-
private final SSLHelper sslHelper;
38+
private final SslContextManager sslContextManager;
3839

3940
public MSSQLConnectionFactory(VertxInternal vertx) {
4041
super(vertx);
41-
sslHelper = new SSLHelper(SSLHelper.resolveEngineOptions(tcpOptions.getSslEngineOptions(), tcpOptions.isUseAlpn()));
42+
sslContextManager = new SslContextManager(NetServerImpl.resolveEngineOptions(tcpOptions.getSslEngineOptions(), tcpOptions.isUseAlpn()));
4243
}
4344

4445
@Override
@@ -78,7 +79,7 @@ private Future<Connection> connectOrRedirect(MSSQLConnectOptions options, Contex
7879
private MSSQLSocketConnection createSocketConnection(NetSocket so, MSSQLConnectOptions options, ContextInternal context) {
7980
VertxMetrics vertxMetrics = vertx.metricsSPI();
8081
ClientMetrics metrics = vertxMetrics != null ? vertxMetrics.createClientMetrics(options.getSocketAddress(), "sql", tcpOptions.getMetricsName()) : null;
81-
MSSQLSocketConnection conn = new MSSQLSocketConnection((NetSocketInternal) so, sslHelper, metrics, options, false, 0, sql -> true, 1, context);
82+
MSSQLSocketConnection conn = new MSSQLSocketConnection((NetSocketInternal) so, sslContextManager, metrics, options, false, 0, sql -> true, 1, context);
8283
conn.init();
8384
return conn;
8485
}

vertx-mssql-client/src/main/java/io/vertx/mssqlclient/impl/MSSQLSocketConnection.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
import io.vertx.core.Handler;
2020
import io.vertx.core.internal.ContextInternal;
2121
import io.vertx.core.internal.PromiseInternal;
22+
import io.vertx.core.internal.tls.SslContextManager;
2223
import io.vertx.core.net.ClientSSLOptions;
2324
import io.vertx.core.net.HostAndPort;
2425
import io.vertx.core.internal.net.NetSocketInternal;
25-
import io.vertx.core.net.impl.SSLHelper;
26-
import io.vertx.core.net.impl.SslChannelProvider;
27-
import io.vertx.core.net.impl.SslHandshakeCompletionHandler;
26+
import io.vertx.core.internal.net.SslChannelProvider;
27+
import io.vertx.core.internal.net.SslHandshakeCompletionHandler;
2828
import io.vertx.core.spi.metrics.ClientMetrics;
2929
import io.vertx.mssqlclient.MSSQLConnectOptions;
3030
import io.vertx.mssqlclient.MSSQLInfo;
@@ -48,13 +48,13 @@
4848
public class MSSQLSocketConnection extends SocketConnectionBase {
4949

5050
private final MSSQLConnectOptions connectOptions;
51-
private final SSLHelper sslHelper;
51+
private final SslContextManager SslContextManager;
5252

5353
private MSSQLDatabaseMetadata databaseMetadata;
5454
private HostAndPort alternateServer;
5555

5656
MSSQLSocketConnection(NetSocketInternal socket,
57-
SSLHelper sslHelper,
57+
SslContextManager SslContextManager,
5858
ClientMetrics clientMetrics,
5959
MSSQLConnectOptions connectOptions,
6060
boolean cachePreparedStatements,
@@ -64,7 +64,7 @@ public class MSSQLSocketConnection extends SocketConnectionBase {
6464
ContextInternal context) {
6565
super(socket, clientMetrics, cachePreparedStatements, preparedStatementCacheSize, preparedStatementCacheSqlFilter, pipeliningLimit, context);
6666
this.connectOptions = connectOptions;
67-
this.sslHelper = sslHelper;
67+
this.SslContextManager = SslContextManager;
6868
}
6969

7070
@Override
@@ -111,7 +111,9 @@ Future<Void> enableSsl(boolean clientConfigSsl, byte encryptionLevel, MSSQLConne
111111

112112
// 2. Create and set up an SSLHelper and SSLHandler
113113
// options.getApplicationLayerProtocols()
114-
Future<SslChannelProvider> f = sslHelper.resolveSslChannelProvider(sslOptions, "", false, null, null, context);
114+
Future<SslChannelProvider> f = SslContextManager
115+
.resolveSslContextProvider(sslOptions, "", null, null, context)
116+
.map(provider -> new SslChannelProvider(context.owner(), provider, false));
115117
return f.compose(provider -> {
116118
SslHandler sslHandler = provider.createClientSslHandler(socket.remoteAddress(), null, sslOptions.isUseAlpn(), sslOptions.getSslHandshakeTimeout(), sslOptions.getSslHandshakeTimeoutUnit());
117119

0 commit comments

Comments
 (0)