|
105 | 105 | * all members of the set.</li>
|
106 | 106 | * </ul>
|
107 | 107 | * <p>Connection Configuration:</p>
|
108 |
| - * <p>Connection Configuration:</p> |
109 | 108 | * <ul>
|
110 |
| - * <li>{@code streamType=nio2|netty}: The stream type to use for connections. If unspecified, nio2 will be used for asynchronous |
111 |
| - * clients. Note that this query parameter has been deprecated and applications should use |
112 |
| - * {@link MongoClientSettings.Builder#streamFactoryFactory(StreamFactoryFactory)} instead.</li> |
113 |
| - * <li>{@code ssl=true|false}: Whether to connect using SSL.</li> |
114 |
| - * <li>{@code sslInvalidHostNameAllowed=true|false}: Whether to allow invalid host names for SSL connections.</li> |
| 109 | + * <li>{@code ssl=true|false}: Whether to connect using TLS.</li> |
| 110 | + * <li>{@code tls=true|false}: Whether to connect using TLS. Supersedes the ssl option</li> |
| 111 | + * <li>{@code tlsInsecure=true|false}: If connecting with TLS, this option enables insecure TLS connections. Currently this has the |
| 112 | + * same effect of setting tlsAllowInvalidHostnames to true. Other mechanism for relaxing TLS security constraints must be handled in |
| 113 | + * the application by customizing the {@link javax.net.ssl.SSLContext}</li> |
| 114 | + * <li>{@code sslInvalidHostNameAllowed=true|false}: Whether to allow invalid host names for TLS connections.</li> |
| 115 | + * <li>{@code tlsAllowInvalidHostnames=true|false}: Whether to allow invalid host names for TLS connections. Supersedes the |
| 116 | + * sslInvalidHostNameAllowed option</li> |
115 | 117 | * <li>{@code connectTimeoutMS=ms}: How long a connection can take to be opened before timing out.</li>
|
116 | 118 | * <li>{@code socketTimeoutMS=ms}: How long a send or receive on a socket can take before timing out.</li>
|
117 | 119 | * <li>{@code maxIdleTimeMS=ms}: Maximum idle time of a pooled connection. A connection that exceeds this limit will be closed</li>
|
118 | 120 | * <li>{@code maxLifeTimeMS=ms}: Maximum life time of a pooled connection. A connection that exceeds this limit will be closed</li>
|
| 121 | + * <li>{@code streamType=nio2|netty}: The stream type to use for connections. If unspecified, nio2 will be used for asynchronous |
| 122 | + * clients. Note that this query parameter has been deprecated and applications should use |
| 123 | + * {@link MongoClientSettings.Builder#streamFactoryFactory(StreamFactoryFactory)} instead.</li> |
119 | 124 | * </ul>
|
120 | 125 | * <p>Connection pool configuration:</p>
|
121 | 126 | * <ul>
|
@@ -396,11 +401,23 @@ public ConnectionString(final String connectionString) {
|
396 | 401 | GENERAL_OPTIONS_KEYS.add("maxidletimems");
|
397 | 402 | GENERAL_OPTIONS_KEYS.add("maxlifetimems");
|
398 | 403 | GENERAL_OPTIONS_KEYS.add("sockettimeoutms");
|
| 404 | + |
| 405 | + // Order matters here: Having tls after ssl means than the tls option will supersede the ssl option when both are set |
399 | 406 | GENERAL_OPTIONS_KEYS.add("ssl");
|
400 |
| - GENERAL_OPTIONS_KEYS.add("streamtype"); |
| 407 | + GENERAL_OPTIONS_KEYS.add("tls"); |
| 408 | + |
| 409 | + // Order matters here: Having tlsinsecure before sslinvalidhostnameallowed and tlsallowinvalidhostnames means that those options |
| 410 | + // will supersede this one when both are set. |
| 411 | + GENERAL_OPTIONS_KEYS.add("tlsinsecure"); |
| 412 | + |
| 413 | + // Order matters here: Having tlsallowinvalidhostnames after sslinvalidhostnameallowed means than the tlsallowinvalidhostnames |
| 414 | + // option will supersede the sslinvalidhostnameallowed option when both are set |
401 | 415 | GENERAL_OPTIONS_KEYS.add("sslinvalidhostnameallowed");
|
| 416 | + GENERAL_OPTIONS_KEYS.add("tlsallowinvalidhostnames"); |
| 417 | + |
402 | 418 | GENERAL_OPTIONS_KEYS.add("replicaset");
|
403 | 419 | GENERAL_OPTIONS_KEYS.add("readconcernlevel");
|
| 420 | + GENERAL_OPTIONS_KEYS.add("streamtype"); |
404 | 421 |
|
405 | 422 | GENERAL_OPTIONS_KEYS.add("serverselectiontimeoutms");
|
406 | 423 | GENERAL_OPTIONS_KEYS.add("localthresholdms");
|
@@ -479,10 +496,16 @@ private void translateOptions(final Map<String, List<String>> optionsMap) {
|
479 | 496 | connectTimeout = parseInteger(value, "connecttimeoutms");
|
480 | 497 | } else if (key.equals("sockettimeoutms")) {
|
481 | 498 | socketTimeout = parseInteger(value, "sockettimeoutms");
|
| 499 | + } else if (key.equals("tlsallowinvalidhostnames")) { |
| 500 | + sslInvalidHostnameAllowed = parseBoolean(value, "tlsAllowInvalidHostnames"); |
482 | 501 | } else if (key.equals("sslinvalidhostnameallowed")) {
|
483 | 502 | sslInvalidHostnameAllowed = parseBoolean(value, "sslinvalidhostnameallowed");
|
| 503 | + } else if (key.equals("tlsinsecure")) { |
| 504 | + sslInvalidHostnameAllowed = parseBoolean(value, "tlsinsecure"); |
484 | 505 | } else if (key.equals("ssl")) {
|
485 | 506 | sslEnabled = parseBoolean(value, "ssl");
|
| 507 | + } else if (key.equals("tls")) { |
| 508 | + sslEnabled = parseBoolean(value, "tls"); |
486 | 509 | } else if (key.equals("streamtype")) {
|
487 | 510 | streamType = value;
|
488 | 511 | LOGGER.warn("The streamType query parameter is deprecated and support for it will be removed"
|
|
0 commit comments