@@ -303,34 +303,21 @@ To restrict your application to use only the TLS 1.2 protocol, set the
303
303
the TLS 1.2 protocol, upgrade to a later release to connect by using
304
304
TLS 1.2.
305
305
306
- .. _tls-custom-sslContext:
307
-
308
- Customize TLS/SSL Configuration through the Java SE SSLContext
309
- --------------------------------------------------------------
306
+ .. _java-netty-sslcontext:
310
307
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
+ ------------------------------------------------------------
316
310
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.
318
315
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::
327
317
328
- Customize TLS/SSL Configuration through the Netty SslContext
329
- ------------------------------------------------------------
318
+ The driver tests with Netty version ``{+nettyVersion+}``
330
319
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:
334
321
335
322
.. code-block:: java
336
323
:copyable: true
@@ -342,39 +329,59 @@ provided by Netty.
342
329
import io.netty.handler.ssl.SslContextBuilder;
343
330
import io.netty.handler.ssl.SslProvider;
344
331
345
- .. note::
346
-
347
- The driver tests with Netty version ``{+nettyVersion+}``
348
-
349
332
To instruct the driver to use
350
333
`io.netty.handler.ssl.SslContext <https://netty.io/4.1/api/io/netty/handler/ssl/SslContext.html>`__,
351
334
configure
352
335
`NettyTransportSettings <{+core-api+}/connection/NettyTransportSettings.html>`__
353
336
when you define your `MongoClientSettings <{+core-api+}/MongoClientSettings.html>`__.
354
- Use `MongoClientSettings.Builder.transportSettings
337
+
338
+ Use `MongoClientSettings.Builder.transportSettings()
355
339
<{+core-api+}/MongoClientSettings.Builder.html#transportSettings(com.mongodb.connection.TransportSettings)>`__
356
- and `NettyTransportSettings.Builder.sslContext
340
+ and `NettyTransportSettings.Builder.sslContext()
357
341
<{+core-api+}/connection/NettyTransportSettings.Builder.html#sslContext(io.netty.handler.ssl.SslContext)>`__
358
342
to build your settings:
359
343
360
344
.. code-block:: java
361
- :emphasize-lines: 3-8
345
+ :emphasize-lines: 7-9
362
346
:copyable: true
363
347
364
348
SslContext sslContext = SslContextBuilder.forClient()
365
349
.sslProvider(SslProvider.OPENSSL)
366
350
.build();
351
+
367
352
MongoClientSettings settings = MongoClientSettings.builder()
368
353
.applyToSslSettings(builder -> builder.enabled(true))
369
354
.transportSettings(TransportSettings.nettyBuilder()
370
355
.sslContext(sslContext)
371
356
.build())
372
357
.build();
358
+
373
359
MongoClient client = MongoClients.create(settings);
374
360
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);
378
385
379
386
Online Certificate Status Protocol (OCSP)
380
387
-----------------------------------------
0 commit comments