Skip to content

Commit 01f2055

Browse files
committed
CDRIVER-2545 use native TLS by default
The driver now uses Windows or Mac native TLS by default, instead of searching for OpenSSL. Override with cmake -DENABLE_SSL=OPENSSL.
1 parent e025efb commit 01f2055

File tree

4 files changed

+12
-94
lines changed

4 files changed

+12
-94
lines changed

CMakeLists.txt

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,9 @@ if (NOT ENABLE_SSL MATCHES "DARWIN|WINDOWS|OPENSSL|LIBRESSL|AUTO|OFF")
155155
endif ()
156156

157157
if (NOT ENABLE_SSL STREQUAL OFF)
158-
# If "AUTO", try OpenSSL. In version 2.0 we'll default to "DARWIN" on Mac.
159-
if (ENABLE_SSL MATCHES "AUTO|OPENSSL")
158+
# Try OpenSSL automatically everywhere but Mac and Windows.
159+
if (ENABLE_SSL STREQUAL "OPENSSL"
160+
OR (NOT APPLE AND NOT WIN32 AND ENABLE_SSL STREQUAL "AUTO"))
160161
# Sets OPENSSL_FOUND on success.
161162
include (FindOpenSSL)
162163
endif ()
@@ -176,30 +177,22 @@ if (NOT ENABLE_SSL STREQUAL OFF)
176177
endif ()
177178
endif ()
178179

179-
if (ENABLE_SSL STREQUAL DARWIN)
180+
if (ENABLE_SSL STREQUAL DARWIN OR (APPLE AND ENABLE_SSL STREQUAL "AUTO"))
180181
if (APPLE)
181182
set (SECURE_TRANSPORT 1)
182183
else ()
183184
message (FATAL_ERROR "ENABLE_SSL=DARWIN only supported on Mac OS X")
184185
endif ()
185186
endif ()
186187

187-
if (ENABLE_SSL STREQUAL AUTO AND NOT OPENSSL_FOUND AND APPLE)
188-
set (SECURE_TRANSPORT 1)
189-
endif ()
190-
191-
if (ENABLE_SSL STREQUAL WINDOWS)
188+
if (ENABLE_SSL STREQUAL WINDOWS OR (WIN32 AND ENABLE_SSL STREQUAL "AUTO"))
192189
if (WIN32)
193190
set (SECURE_CHANNEL 1)
194191
else ()
195192
message (FATAL_ERROR "ENABLE_SSL=WINDOWS only supported on Windows")
196193
endif ()
197194
endif ()
198195

199-
if (ENABLE_SSL STREQUAL AUTO AND NOT OPENSSL_FOUND AND WIN32)
200-
set (SECURE_CHANNEL 1)
201-
endif ()
202-
203196
if (NOT OPENSSL_FOUND AND NOT SECURE_TRANSPORT AND NOT SECURE_CHANNEL AND NOT LIBRESSL)
204197
if (ENABLE_SSL STREQUAL AUTO)
205198
set (ENABLE_SSL OFF)

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ bugfixes:
1313
* The internal preprocessor symbol HAVE_STRINGS_H has been renamed
1414
BSON_HAVE_STRINGS_H. If you maintain a handwritten bson-config.h you must
1515
rename this symbol.
16+
* If CMake is configured with ENABLE_SSL=AUTO (the default), libmongoc now
17+
uses native TLS libraries on Mac and Windows, and OpenSSL everywhere else.
18+
Before, it would search for OpenSSL on all platforms and only use native
19+
TLS on Mac and Windows as a fallback.
1620
* The driver now handshakes SSL connections to multiple servers in a replica
1721
set or sharded cluster in parallel, so long as it uses OpenSSL or Windows
1822
SChannel. (SSL handshakes with Apple's Secure Transport are still serial.)

doc/installing.rst

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -190,33 +190,6 @@ Build and install the driver:
190190
$ make
191191
$ sudo make install
192192
193-
Native TLS Support on Mac OS X / Darwin (Secure Transport)
194-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
195-
196-
The MongoDB C Driver supports the Darwin native TLS and crypto libraries.
197-
Using the native libraries there is no need to install OpenSSL. By
198-
default however, the driver will compile against OpenSSL if it
199-
detects it being available. If OpenSSL is not available, it will
200-
fall back on the native libraries.
201-
202-
To compile against the Darwin native TLS and crypto libraries, even when
203-
OpenSSL is available, configure the driver like so:
204-
205-
.. code-block:: none
206-
207-
$ ./configure --enable-ssl=darwin
208-
209-
OpenSSL support in Mac OS X
210-
^^^^^^^^^^^^^^^^^^^^^^^^^^^
211-
212-
Beginning in OS X 10.11 El Capitan, OS X no longer includes the OpenSSL headers. To build the driver with OpenSSL on El Capitan and later:
213-
214-
.. code-block:: none
215-
216-
$ brew install openssl
217-
$ export LDFLAGS="-L/usr/local/opt/openssl/lib"
218-
$ export CPPFLAGS="-I/usr/local/opt/openssl/include"
219-
220193
.. _build-on-windows:
221194

222195
Building on Windows with Visual Studio
@@ -260,8 +233,6 @@ Now let's do the same for the MongoDB C driver.
260233
mkdir cmake-build
261234
cd cmake-build
262235
cmake -G "Visual Studio 14 2015 Win64" \\
263-
"-DENABLE_SSL=WINDOWS" \\
264-
"-DENABLE_SASL=SSPI" \\
265236
"-DCMAKE_INSTALL_PREFIX=C:\\mongo-c-driver" \\
266237
"-DCMAKE_PREFIX_PATH=C:\\mongo-c-driver" \\
267238
"-DCMAKE_BUILD_TYPE=Release" \\
@@ -278,52 +249,6 @@ To build and install debug binaries, remove the
278249

279250
To use the driver libraries in your program, see :doc:`visual-studio-guide`.
280251

281-
Native TLS Support on Windows (Secure Channel)
282-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
283-
284-
The MongoDB C Driver supports the Windows native TLS and crypto libraries.
285-
Using the native libraries there is no need to install OpenSSL. By
286-
default however, the driver will compile against OpenSSL if it
287-
detects it being available. If OpenSSL is not available, it will
288-
fallback on the native libraries.
289-
290-
To compile against the Windows native TLS and crypto libraries, even when
291-
OpenSSL is available, configure the driver like so:
292-
293-
.. code-block:: none
294-
295-
cmake -G "Visual Studio 14 2015 Win64" \
296-
"-DENABLE_SSL=WINDOWS" \
297-
"-DCMAKE_INSTALL_PREFIX=C:\\mongo-c-driver" \
298-
"-DCMAKE_PREFIX_PATH=C:\\mongo-c-driver" \
299-
..
300-
301-
Native SASL Support on Windows (SSPI)
302-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
303-
304-
The MongoDB C Driver supports the Windows native Kerberos and Active Directory
305-
interface, SSPI. Using the native libraries there is no need to install any
306-
dependencies, such as cyrus-sasl. By default however, the driver will compile
307-
against cyrus-sasl.
308-
309-
To compile against the Windows native SSPI, configure the driver like so:
310-
311-
.. code-block:: none
312-
313-
cmake -G "Visual Studio 14 2015 Win64" \
314-
"-DENABLE_SASL=SSPI" \
315-
"-DCMAKE_INSTALL_PREFIX=C:\\mongo-c-driver" \
316-
"-DCMAKE_PREFIX_PATH=C:\\mongo-c-driver" \
317-
..
318-
319-
OpenSSL support on Windows
320-
^^^^^^^^^^^^^^^^^^^^^^^^^^
321-
322-
For backwards compatibility CMake will default to OpenSSL support.
323-
If not found, it will fallback to native TLS support provided by the platform.
324-
325-
OpenSSL 1.1.0 support requires CMake 3.7 or later on Windows.
326-
327252
Building on Windows with MinGW-W64 and MSYS2
328253
--------------------------------------------
329254

doc/mongoc_ssl_opt_t.rst

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,11 @@ To overwrite this behaviour, it is possible to disable hostname validation, and/
7272
OpenSSL
7373
-------
7474

75-
The MongoDB C Driver uses OpenSSL, if available, on Linux and Unix platforms, including macOS.
76-
77-
Industry best practices and some regulations require the use of TLS 1.1 or newer, which requires at least OpenSSL 1.0.1. However, some operating systems such as older macOS ship outdated OpenSSL libraries. Check your OpenSSL version like so::
75+
The MongoDB C Driver uses OpenSSL, if available, on Linux and Unix platforms (besides macOS). Industry best practices and some regulations require the use of TLS 1.1 or newer, which requires at least OpenSSL 1.0.1. Check your OpenSSL version like so::
7876

7977
$ openssl version
8078

81-
On macOS we recommend using `Secure Transport`_ instead. On other Unixes, upgrade your OpenSSL to a recent version (at least 1.0.1), or install a recent version in a non-system path and build against it with::
79+
Ensure your system's OpenSSL is a recent version (at least 1.0.1), or install a recent version in a non-system path and build against it with::
8280

8381
cmake -DOPENSSL_ROOT_DIR=/absolute/path/to/openssl
8482

@@ -107,9 +105,7 @@ When ``crl_file`` is provided, the driver will import the revocation list to the
107105
Native TLS Support on Mac OS X / Darwin (Secure Transport)
108106
----------------------------------------------------------
109107

110-
The MongoDB C Driver supports the Darwin (OS X, macOS, iOS, etc.) native TLS library (Secure Transport), and its native crypto library (Common Crypto, or CC). To ensure you build with Secure Transport instead of any OpenSSL library installed on your system::
111-
112-
cmake -DENABLE_SSL=DARWIN
108+
The MongoDB C Driver supports the Darwin (OS X, macOS, iOS, etc.) native TLS library (Secure Transport), and its native crypto library (Common Crypto, or CC).
113109

114110
When compiled against Secure Transport, the ``ca_dir`` option is not supported, and will issue an error if used.
115111

0 commit comments

Comments
 (0)