Skip to content

Commit 6684653

Browse files
pwaehnertbagder
authored andcommitted
configure: add option to disable automatic OpenSSL config loading
Sometimes it may be considered a security risk to load an external OpenSSL configuration automatically inside curl_global_init(). The configuration option --disable-ssl-auto-load-config disables this automatism. The Windows build scripts winbuild/Makefile.vs provide a corresponding option ENABLE_SSL_AUTO_LOAD_CONFIG accepting a boolean value. Setting neither of these options corresponds to the previous behavior loading the external OpenSSL configuration automatically. Fixes #2724 Closes #2791
1 parent c515294 commit 6684653

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

configure.ac

+14
Original file line numberDiff line numberDiff line change
@@ -1876,6 +1876,20 @@ if test "$OPENSSL_ENABLED" = "1"; then
18761876
])
18771877
fi
18781878

1879+
dnl ---
1880+
dnl Whether the OpenSSL configuration will be loaded automatically
1881+
dnl ---
1882+
if test X"$OPENSSL_ENABLED" = X"1"; then
1883+
AC_ARG_ENABLE(openssl-auto-load-config,
1884+
AC_HELP_STRING([--enable-openssl-auto-load-config],[Enable automatic loading of OpenSSL configuration])
1885+
AC_HELP_STRING([--disable-openssl-auto-load-config],[Disable automatic loading of OpenSSL configuration]),
1886+
[ if test X"$enableval" = X"no"; then
1887+
AC_MSG_NOTICE([automatic loading of OpenSSL configuration disabled])
1888+
AC_DEFINE(CURL_DISABLE_OPENSSL_AUTO_LOAD_CONFIG, 1, [if the OpenSSL configuration won't be loaded automatically])
1889+
fi
1890+
])
1891+
fi
1892+
18791893
dnl ----------------------------------------------------
18801894
dnl check for GnuTLS
18811895
dnl ----------------------------------------------------

lib/vtls/openssl.c

+2
Original file line numberDiff line numberDiff line change
@@ -994,9 +994,11 @@ static int Curl_ossl_init(void)
994994
#define CONF_MFLAGS_DEFAULT_SECTION 0x0
995995
#endif
996996

997+
#ifndef CURL_DISABLE_OPENSSL_AUTO_LOAD_CONFIG
997998
CONF_modules_load_file(NULL, NULL,
998999
CONF_MFLAGS_DEFAULT_SECTION|
9991000
CONF_MFLAGS_IGNORE_MISSING_FILE);
1001+
#endif
10001002

10011003
#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && \
10021004
!defined(LIBRESSL_VERSION_NUMBER)

winbuild/Makefile.vc

+6
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ CFGSET=true
5353
!MESSAGE ENABLE_IPV6=<yes or no> - Enable IPv6, defaults to yes
5454
!MESSAGE ENABLE_SSPI=<yes or no> - Enable SSPI support, defaults to yes
5555
!MESSAGE ENABLE_WINSSL=<yes or no> - Enable native Windows SSL support, defaults to yes
56+
!MESSAGE ENABLE_OPENSSL_AUTO_LOAD_CONFIG=<yes or no>
57+
!MESSAGE - Whether the OpenSSL configuration will be loaded automatically, defaults to yes
5658
!MESSAGE GEN_PDB=<yes or no> - Generate Program Database (debug symbols for release build)
5759
!MESSAGE DEBUG=<yes or no> - Debug builds
5860
!MESSAGE MACHINE=<x86 or x64> - Target architecture (default x64 on AMD64, x86 on others)
@@ -130,6 +132,10 @@ USE_WINSSL = true
130132
USE_WINSSL = false
131133
!ENDIF
132134

135+
!IFNDEF ENABLE_OPENSSL_AUTO_LOAD_CONFIG
136+
ENABLE_OPENSSL_AUTO_LOAD_CONFIG = true
137+
!ENDIF
138+
133139
CONFIG_NAME_LIB = libcurl
134140

135141
!IF "$(WITH_SSL)"=="dll"

winbuild/MakefileBuild.vc

+3
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ SSL_CFLAGS = /DUSE_OPENSSL /I"$(SSL_INC_DIR)"
152152
!IF EXISTS("$(SSL_INC_DIR)\is_boringssl.h")
153153
SSL_CFLAGS = $(SSL_CFLAGS) /DHAVE_BORINGSSL
154154
!ENDIF
155+
!IF "$(ENABLE_OPENSSL_AUTO_LOAD_CONFIG)"=="false"
156+
SSL_CFLAGS = $(SSL_CFLAGS) /DCURL_DISABLE_OPENSSL_AUTO_LOAD_CONFIG
157+
!ENDIF
155158
!ENDIF
156159

157160

0 commit comments

Comments
 (0)