@@ -303,34 +303,21 @@ To restrict your application to use only the TLS 1.2 protocol, set the
303303 the TLS 1.2 protocol, upgrade to a later release to connect by using
304304 TLS 1.2.
305305
306- .. _tls-custom-sslContext:
307-
308- Customize TLS/SSL Configuration through the Java SE SSLContext
309- --------------------------------------------------------------
306+ .. _java-netty-sslcontext:
310307
311- If your TLS/SSL configuration requires customization, you can
312- set the ``sslContext`` property of your ``MongoClient`` by
313- passing an `SSLContext
314- <https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/SSLContext.html>`__
315- object to the builder in the ``applyToSslSettings()`` lambda:
308+ Customize TLS/SSL Configuration through the Netty SslContext
309+ ------------------------------------------------------------
316310
317- .. code-block:: java
311+ We recommend using `Netty <https://netty.io/>`__ for network IO, as
312+ Netty supports non-blocking, asynchronous IO and handles high connection
313+ volumes effectively. When using Netty, you can plug an alternative
314+ TLS/SSL protocol implementation.
318315
319- SSLContext sslContext = ...
320- MongoClientSettings settings = MongoClientSettings.builder()
321- .applyToSslSettings(builder -> {
322- builder.enabled(true);
323- builder.context(sslContext);
324- })
325- .build();
326- MongoClient client = MongoClients.create(settings);
316+ .. note::
327317
328- Customize TLS/SSL Configuration through the Netty SslContext
329- ------------------------------------------------------------
318+ The driver tests with Netty version ``{+nettyVersion+}``
330319
331- If you use the driver with `Netty <https://netty.io/>`__ for network IO,
332- you have an option to plug an alternative TLS/SSL protocol implementation
333- provided by Netty.
320+ The example in this section requires the following import statements:
334321
335322.. code-block:: java
336323 :copyable: true
@@ -342,39 +329,59 @@ provided by Netty.
342329 import io.netty.handler.ssl.SslContextBuilder;
343330 import io.netty.handler.ssl.SslProvider;
344331
345- .. note::
346-
347- The driver tests with Netty version ``{+nettyVersion+}``
348-
349332To instruct the driver to use
350333`io.netty.handler.ssl.SslContext <https://netty.io/4.1/api/io/netty/handler/ssl/SslContext.html>`__,
351334configure
352335`NettyTransportSettings <{+core-api+}/connection/NettyTransportSettings.html>`__
353336when you define your `MongoClientSettings <{+core-api+}/MongoClientSettings.html>`__.
354- Use `MongoClientSettings.Builder.transportSettings
337+
338+ Use `MongoClientSettings.Builder.transportSettings()
355339<{+core-api+}/MongoClientSettings.Builder.html#transportSettings(com.mongodb.connection.TransportSettings)>`__
356- and `NettyTransportSettings.Builder.sslContext
340+ and `NettyTransportSettings.Builder.sslContext()
357341<{+core-api+}/connection/NettyTransportSettings.Builder.html#sslContext(io.netty.handler.ssl.SslContext)>`__
358342to build your settings:
359343
360344.. code-block:: java
361- :emphasize-lines: 3-8
345+ :emphasize-lines: 7-9
362346 :copyable: true
363347
364348 SslContext sslContext = SslContextBuilder.forClient()
365349 .sslProvider(SslProvider.OPENSSL)
366350 .build();
351+
367352 MongoClientSettings settings = MongoClientSettings.builder()
368353 .applyToSslSettings(builder -> builder.enabled(true))
369354 .transportSettings(TransportSettings.nettyBuilder()
370355 .sslContext(sslContext)
371356 .build())
372357 .build();
358+
373359 MongoClient client = MongoClients.create(settings);
374360
375- For more details about the ``io.netty.handler.ssl.SslProvider``, see the `Netty
376- documentation
377- <https://netty.io/4.1/api/io/netty/handler/ssl/SslProvider.html>`__
361+ To learn more about the ``io.netty.handler.ssl.SslProvider``, see the `Netty
362+ documentation <https://netty.io/4.1/api/io/netty/handler/ssl/SslProvider.html>`__.
363+
364+ .. _tls-custom-sslContext:
365+
366+ Customize TLS/SSL Configuration through the Java SE SSLContext
367+ --------------------------------------------------------------
368+
369+ If your TLS/SSL configuration requires customization, you can
370+ set the ``sslContext`` property of your ``MongoClient`` by
371+ passing an `SSLContext
372+ <https://docs.oracle.com/javase/8/docs/api/javax/net/ssl/SSLContext.html>`__
373+ object to the builder in the ``applyToSslSettings()`` lambda:
374+
375+ .. code-block:: java
376+
377+ SSLContext sslContext = ...
378+ MongoClientSettings settings = MongoClientSettings.builder()
379+ .applyToSslSettings(builder -> {
380+ builder.enabled(true);
381+ builder.context(sslContext);
382+ })
383+ .build();
384+ MongoClient client = MongoClients.create(settings);
378385
379386Online Certificate Status Protocol (OCSP)
380387-----------------------------------------
0 commit comments