curl-openssl.m4 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) 1998 - 2021, Daniel Stenberg, <[email protected]>, et al.
  9. #
  10. # This software is licensed as described in the file COPYING, which
  11. # you should have received as part of this distribution. The terms
  12. # are also available at https://curl.se/docs/copyright.html.
  13. #
  14. # You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. # copies of the Software, and permit persons to whom the Software is
  16. # furnished to do so, under the terms of the COPYING file.
  17. #
  18. # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. # KIND, either express or implied.
  20. #
  21. #***************************************************************************
  22. # File version for 'aclocal' use. Keep it a single number.
  23. # serial 5
  24. dnl CURL_CHECK_OPENSSL_API_HEADERS
  25. dnl -------------------------------------------------
  26. dnl Find out OpenSSL headers API version, as reported
  27. dnl by OPENSSL_VERSION_NUMBER. No runtime checks
  28. dnl allowed here for cross-compilation support.
  29. dnl HAVE_OPENSSL_API_HEADERS is defined as appropriate
  30. dnl only for systems which actually run the configure
  31. dnl script. Config files generated manually or in any
  32. dnl other way shall not define this.
  33. AC_DEFUN([CURL_CHECK_OPENSSL_API_HEADERS], [
  34. #
  35. tst_api="unknown"
  36. #
  37. AC_MSG_CHECKING([for OpenSSL headers version])
  38. CURL_CHECK_DEF([OPENSSL_VERSION_NUMBER], [
  39. # ifdef USE_OPENSSL
  40. # include <openssl/crypto.h>
  41. # else
  42. # include <crypto.h>
  43. # endif
  44. ], [silent])
  45. CURL_CHECK_DEF([OPENSSL_VERSION_STR], [
  46. # include <openssl/crypto.h>
  47. ], [silent])
  48. if test "$curl_cv_have_def_OPENSSL_VERSION_NUMBER" = "yes"; then
  49. tst_verlen=`expr "$curl_cv_def_OPENSSL_VERSION_NUMBER" : '.*'`
  50. case "x$tst_verlen" in
  51. x6)
  52. tst_vermaj=`echo $curl_cv_def_OPENSSL_VERSION_NUMBER | cut -c 3`
  53. tst_vermin=`echo $curl_cv_def_OPENSSL_VERSION_NUMBER | cut -c 4`
  54. tst_verfix=`echo $curl_cv_def_OPENSSL_VERSION_NUMBER | cut -c 5`
  55. tst_api=0x$tst_vermaj$tst_vermin$tst_verfix
  56. ;;
  57. x11|x10)
  58. tst_vermaj=`echo $curl_cv_def_OPENSSL_VERSION_NUMBER | cut -c 3`
  59. tst_vermin=`echo $curl_cv_def_OPENSSL_VERSION_NUMBER | cut -c 5`
  60. tst_verfix=`echo $curl_cv_def_OPENSSL_VERSION_NUMBER | cut -c 7`
  61. tst_api=0x$tst_vermaj$tst_vermin$tst_verfix
  62. ;;
  63. *)
  64. if test "$curl_cv_have_def_OPENSSL_VERSION_STR" = "yes"; then
  65. ver=`echo $curl_cv_def_OPENSSL_VERSION_STR | sed 's/"//g'`;
  66. tst_vermaj=`echo $ver | cut -d. -f1`
  67. tst_vermin=`echo $ver | cut -d. -f2`
  68. tst_verfix=`echo $ver | cut -d. -f3`
  69. tst_show="$ver"
  70. tst_api=0x$tst_vermaj$tst_vermin$tst_verfix
  71. else
  72. tst_api="unknown"
  73. fi
  74. ;;
  75. esac
  76. case $tst_api in
  77. 0x111) tst_show="1.1.1" ;;
  78. 0x110) tst_show="1.1.0" ;;
  79. 0x102) tst_show="1.0.2" ;;
  80. 0x101) tst_show="1.0.1" ;;
  81. 0x100) tst_show="1.0.0" ;;
  82. 0x099) tst_show="0.9.9" ;;
  83. 0x098) tst_show="0.9.8" ;;
  84. 0x097) tst_show="0.9.7" ;;
  85. 0x096) tst_show="0.9.6" ;;
  86. 0x095) tst_show="0.9.5" ;;
  87. 0x094) tst_show="0.9.4" ;;
  88. 0x093) tst_show="0.9.3" ;;
  89. 0x092) tst_show="0.9.2" ;;
  90. 0x091) tst_show="0.9.1" ;;
  91. *)
  92. if test -z "$tst_show"; then
  93. tst_show="unknown"
  94. fi
  95. ;;
  96. esac
  97. tst_show="$tst_show - $tst_api"
  98. else
  99. tst_show="unknown"
  100. fi
  101. AC_MSG_RESULT([$tst_show])
  102. #
  103. dnl if test "$tst_api" != "unknown"; then
  104. dnl AC_DEFINE_UNQUOTED(HAVE_OPENSSL_API_HEADERS, $tst_api,
  105. dnl [OpenSSL headers configure time API. Defined only by configure script.
  106. dnl No matter what, do not ever define this manually or by any other means.])
  107. dnl fi
  108. curl_openssl_api_headers=$tst_api
  109. ])
  110. dnl CURL_CHECK_OPENSSL_API_LIBRARY
  111. dnl -------------------------------------------------
  112. dnl Find out OpenSSL library API version, performing
  113. dnl only link tests in order to avoid getting fooled
  114. dnl by mismatched OpenSSL headers. No runtime checks
  115. dnl allowed here for cross-compilation support.
  116. dnl HAVE_OPENSSL_API_LIBRARY is defined as appropriate
  117. dnl only for systems which actually run the configure
  118. dnl script. Config files generated manually or in any
  119. dnl other way shall not define this.
  120. dnl
  121. dnl Most probably we should not bother attempting to
  122. dnl detect OpenSSL library development API versions
  123. dnl 0.9.9 and 1.1.0. For our intended use, detecting
  124. dnl released versions should be good enough.
  125. dnl
  126. dnl Given that currently we are not using the result
  127. dnl of this check, except for informative purposes,
  128. dnl lets try to figure out everything.
  129. AC_DEFUN([CURL_CHECK_OPENSSL_API_LIBRARY], [
  130. #
  131. tst_api="unknown"
  132. #
  133. AC_MSG_CHECKING([for OpenSSL library version])
  134. if test "$tst_api" = "unknown"; then
  135. AC_LINK_IFELSE([
  136. AC_LANG_FUNC_LINK_TRY([SSL_CTX_load_verify_dir])
  137. ],[
  138. tst_api="0x300"
  139. ])
  140. fi
  141. if test "$tst_api" = "unknown"; then
  142. AC_LINK_IFELSE([
  143. AC_LANG_FUNC_LINK_TRY([ERR_clear_last_mark])
  144. ],[
  145. tst_api="0x111"
  146. ])
  147. fi
  148. if test "$tst_api" = "unknown"; then
  149. case $host in
  150. *-*-vms*)
  151. AC_LINK_IFELSE([
  152. AC_LANG_FUNC_LINK_TRY([SSL_CTX_set_not_resumbl_sess_cb])
  153. ],[
  154. tst_api="0x110"
  155. ])
  156. ;;
  157. *)
  158. AC_LINK_IFELSE([
  159. AC_LANG_FUNC_LINK_TRY([SSL_CTX_set_not_resumable_session_callback])
  160. ],[
  161. tst_api="0x110"
  162. ])
  163. ;;
  164. esac
  165. fi
  166. if test "$tst_api" = "unknown"; then
  167. AC_LINK_IFELSE([
  168. AC_LANG_FUNC_LINK_TRY([SSL_CONF_CTX_new])
  169. ],[
  170. tst_api="0x102"
  171. ])
  172. fi
  173. if test "$tst_api" = "unknown"; then
  174. AC_LINK_IFELSE([
  175. AC_LANG_FUNC_LINK_TRY([SSL_renegotiate_abbreviated])
  176. ],[
  177. tst_api="0x101"
  178. ])
  179. fi
  180. if test "$tst_api" = "unknown"; then
  181. AC_LINK_IFELSE([
  182. AC_LANG_FUNC_LINK_TRY([OBJ_add_sigid])
  183. ],[
  184. tst_api="0x100"
  185. ])
  186. fi
  187. if test "$tst_api" = "unknown"; then
  188. AC_LINK_IFELSE([
  189. AC_LANG_FUNC_LINK_TRY([ERR_set_mark])
  190. ],[
  191. tst_api="0x098"
  192. ])
  193. fi
  194. if test "$tst_api" = "unknown"; then
  195. AC_LINK_IFELSE([
  196. AC_LANG_FUNC_LINK_TRY([ERR_peek_last_error])
  197. ],[
  198. tst_api="0x097"
  199. ])
  200. fi
  201. if test "$tst_api" = "unknown"; then
  202. AC_LINK_IFELSE([
  203. AC_LANG_FUNC_LINK_TRY([c2i_ASN1_OBJECT])
  204. ],[
  205. tst_api="0x096"
  206. ])
  207. fi
  208. if test "$tst_api" = "unknown"; then
  209. AC_LINK_IFELSE([
  210. AC_LANG_FUNC_LINK_TRY([SSL_CTX_set_purpose])
  211. ],[
  212. tst_api="0x095"
  213. ])
  214. fi
  215. if test "$tst_api" = "unknown"; then
  216. AC_LINK_IFELSE([
  217. AC_LANG_FUNC_LINK_TRY([OBJ_obj2txt])
  218. ],[
  219. tst_api="0x094"
  220. ])
  221. fi
  222. if test "$tst_api" = "unknown"; then
  223. AC_LINK_IFELSE([
  224. AC_LANG_FUNC_LINK_TRY([SSL_get_verify_depth])
  225. ],[
  226. tst_api="0x093"
  227. ])
  228. fi
  229. if test "$tst_api" = "unknown"; then
  230. AC_LINK_IFELSE([
  231. AC_LANG_FUNC_LINK_TRY([SSL_library_init])
  232. ],[
  233. tst_api="0x092"
  234. ])
  235. fi
  236. if test "$tst_api" = "unknown"; then
  237. AC_LINK_IFELSE([
  238. AC_LANG_FUNC_LINK_TRY([SSL_CTX_set_cipher_list])
  239. ],[
  240. tst_api="0x091"
  241. ])
  242. fi
  243. case $tst_api in
  244. 0x300) tst_show="3.0.0" ;;
  245. 0x111) tst_show="1.1.1" ;;
  246. 0x110) tst_show="1.1.0" ;;
  247. 0x102) tst_show="1.0.2" ;;
  248. 0x101) tst_show="1.0.1" ;;
  249. 0x100) tst_show="1.0.0" ;;
  250. 0x099) tst_show="0.9.9" ;;
  251. 0x098) tst_show="0.9.8" ;;
  252. 0x097) tst_show="0.9.7" ;;
  253. 0x096) tst_show="0.9.6" ;;
  254. 0x095) tst_show="0.9.5" ;;
  255. 0x094) tst_show="0.9.4" ;;
  256. 0x093) tst_show="0.9.3" ;;
  257. 0x092) tst_show="0.9.2" ;;
  258. 0x091) tst_show="0.9.1" ;;
  259. *) tst_show="unknown" ;;
  260. esac
  261. AC_MSG_RESULT([$tst_show])
  262. #
  263. dnl if test "$tst_api" != "unknown"; then
  264. dnl AC_DEFINE_UNQUOTED(HAVE_OPENSSL_API_LIBRARY, $tst_api,
  265. dnl [OpenSSL library link time API. Defined only by configure script.
  266. dnl No matter what, do not ever define this manually or by any other means.])
  267. dnl fi
  268. curl_openssl_api_library=$tst_api
  269. ])
  270. dnl CURL_CHECK_OPENSSL_API
  271. dnl -------------------------------------------------
  272. AC_DEFUN([CURL_CHECK_OPENSSL_API], [
  273. #
  274. CURL_CHECK_OPENSSL_API_HEADERS
  275. CURL_CHECK_OPENSSL_API_LIBRARY
  276. #
  277. tst_match="yes"
  278. #
  279. AC_MSG_CHECKING([for OpenSSL headers and library versions matching])
  280. if test "$curl_openssl_api_headers" = "unknown" ||
  281. test "$curl_openssl_api_library" = "unknown"; then
  282. tst_match="fail"
  283. tst_warns="Can not compare OpenSSL headers and library versions."
  284. elif test "$curl_openssl_api_headers" != "$curl_openssl_api_library"; then
  285. tst_match="no"
  286. tst_warns="OpenSSL headers and library versions do not match."
  287. fi
  288. AC_MSG_RESULT([$tst_match])
  289. if test "$tst_match" != "yes"; then
  290. AC_MSG_WARN([$tst_warns])
  291. fi
  292. ])
  293. dnl **********************************************************************
  294. dnl Check for OpenSSL libraries and headers
  295. dnl **********************************************************************
  296. AC_DEFUN([CURL_WITH_OPENSSL], [
  297. if test "x$OPT_OPENSSL" != xno; then
  298. ssl_msg=
  299. dnl backup the pre-ssl variables
  300. CLEANLDFLAGS="$LDFLAGS"
  301. CLEANCPPFLAGS="$CPPFLAGS"
  302. CLEANLIBS="$LIBS"
  303. dnl This is for Msys/Mingw
  304. case $host in
  305. *-*-msys* | *-*-mingw*)
  306. AC_MSG_CHECKING([for gdi32])
  307. my_ac_save_LIBS=$LIBS
  308. LIBS="-lgdi32 $LIBS"
  309. AC_LINK_IFELSE([ AC_LANG_PROGRAM([[
  310. #include <windef.h>
  311. #include <wingdi.h>
  312. ]],
  313. [[
  314. GdiFlush();
  315. ]])],
  316. [ dnl worked!
  317. AC_MSG_RESULT([yes])],
  318. [ dnl failed, restore LIBS
  319. LIBS=$my_ac_save_LIBS
  320. AC_MSG_RESULT(no)]
  321. )
  322. ;;
  323. esac
  324. case "$OPT_OPENSSL" in
  325. yes)
  326. dnl --with-openssl (without path) used
  327. PKGTEST="yes"
  328. PREFIX_OPENSSL=
  329. ;;
  330. *)
  331. dnl check the given --with-openssl spot
  332. PKGTEST="no"
  333. PREFIX_OPENSSL=$OPT_OPENSSL
  334. dnl Try pkg-config even when cross-compiling. Since we
  335. dnl specify PKG_CONFIG_LIBDIR we're only looking where
  336. dnl the user told us to look
  337. OPENSSL_PCDIR="$OPT_OPENSSL/lib/pkgconfig"
  338. if test -f "$OPENSSL_PCDIR/openssl.pc"; then
  339. AC_MSG_NOTICE([PKG_CONFIG_LIBDIR will be set to "$OPENSSL_PCDIR"])
  340. PKGTEST="yes"
  341. fi
  342. if test "$PKGTEST" != "yes"; then
  343. # try lib64 instead
  344. OPENSSL_PCDIR="$OPT_OPENSSL/lib64/pkgconfig"
  345. if test -f "$OPENSSL_PCDIR/openssl.pc"; then
  346. AC_MSG_NOTICE([PKG_CONFIG_LIBDIR will be set to "$OPENSSL_PCDIR"])
  347. PKGTEST="yes"
  348. fi
  349. fi
  350. if test "$PKGTEST" != "yes"; then
  351. if test ! -f "$PREFIX_OPENSSL/include/openssl/ssl.h"; then
  352. AC_MSG_ERROR([$PREFIX_OPENSSL is a bad --with-openssl prefix!])
  353. fi
  354. fi
  355. dnl in case pkg-config comes up empty, use what we got
  356. dnl via --with-openssl
  357. LIB_OPENSSL="$PREFIX_OPENSSL/lib$libsuff"
  358. if test "$PREFIX_OPENSSL" != "/usr" ; then
  359. SSL_LDFLAGS="-L$LIB_OPENSSL"
  360. SSL_CPPFLAGS="-I$PREFIX_OPENSSL/include"
  361. fi
  362. SSL_CPPFLAGS="$SSL_CPPFLAGS -I$PREFIX_OPENSSL/include/openssl"
  363. ;;
  364. esac
  365. if test "$PKGTEST" = "yes"; then
  366. CURL_CHECK_PKGCONFIG(openssl, [$OPENSSL_PCDIR])
  367. if test "$PKGCONFIG" != "no" ; then
  368. SSL_LIBS=`CURL_EXPORT_PCDIR([$OPENSSL_PCDIR]) dnl
  369. $PKGCONFIG --libs-only-l --libs-only-other openssl 2>/dev/null`
  370. SSL_LDFLAGS=`CURL_EXPORT_PCDIR([$OPENSSL_PCDIR]) dnl
  371. $PKGCONFIG --libs-only-L openssl 2>/dev/null`
  372. SSL_CPPFLAGS=`CURL_EXPORT_PCDIR([$OPENSSL_PCDIR]) dnl
  373. $PKGCONFIG --cflags-only-I openssl 2>/dev/null`
  374. AC_SUBST(SSL_LIBS)
  375. AC_MSG_NOTICE([pkg-config: SSL_LIBS: "$SSL_LIBS"])
  376. AC_MSG_NOTICE([pkg-config: SSL_LDFLAGS: "$SSL_LDFLAGS"])
  377. AC_MSG_NOTICE([pkg-config: SSL_CPPFLAGS: "$SSL_CPPFLAGS"])
  378. LIB_OPENSSL=`echo $SSL_LDFLAGS | sed -e 's/^-L//'`
  379. dnl use the values pkg-config reported. This is here
  380. dnl instead of below with CPPFLAGS and LDFLAGS because we only
  381. dnl learn about this via pkg-config. If we only have
  382. dnl the argument to --with-openssl we don't know what
  383. dnl additional libs may be necessary. Hope that we
  384. dnl don't need any.
  385. LIBS="$SSL_LIBS $LIBS"
  386. fi
  387. fi
  388. dnl finally, set flags to use SSL
  389. CPPFLAGS="$CPPFLAGS $SSL_CPPFLAGS"
  390. LDFLAGS="$LDFLAGS $SSL_LDFLAGS"
  391. AC_CHECK_LIB(crypto, HMAC_Update,[
  392. HAVECRYPTO="yes"
  393. LIBS="-lcrypto $LIBS"
  394. ],[
  395. if test -n "$LIB_OPENSSL" ; then
  396. LDFLAGS="$CLEANLDFLAGS -L$LIB_OPENSSL"
  397. fi
  398. if test "$PKGCONFIG" = "no" -a -n "$PREFIX_OPENSSL" ; then
  399. # only set this if pkg-config wasn't used
  400. CPPFLAGS="$CLEANCPPFLAGS -I$PREFIX_OPENSSL/include/openssl -I$PREFIX_OPENSSL/include"
  401. fi
  402. # Linking previously failed, try extra paths from --with-openssl or
  403. # pkg-config. Use a different function name to avoid reusing the earlier
  404. # cached result.
  405. AC_CHECK_LIB(crypto, HMAC_Init_ex,[
  406. HAVECRYPTO="yes"
  407. LIBS="-lcrypto $LIBS"], [
  408. dnl still no, but what about with -ldl?
  409. AC_MSG_CHECKING([OpenSSL linking with -ldl])
  410. LIBS="-lcrypto $CLEANLIBS -ldl"
  411. AC_LINK_IFELSE([ AC_LANG_PROGRAM([[
  412. #include <openssl/err.h>
  413. ]], [[
  414. ERR_clear_error();
  415. ]]) ],
  416. [
  417. AC_MSG_RESULT(yes)
  418. HAVECRYPTO="yes"
  419. ],
  420. [
  421. AC_MSG_RESULT(no)
  422. dnl ok, so what about both -ldl and -lpthread?
  423. dnl This may be necessary for static libraries.
  424. AC_MSG_CHECKING([OpenSSL linking with -ldl and -lpthread])
  425. LIBS="-lcrypto $CLEANLIBS -ldl -lpthread"
  426. AC_LINK_IFELSE([
  427. AC_LANG_PROGRAM([[
  428. #include <openssl/err.h>
  429. ]], [[
  430. ERR_clear_error();
  431. ]])],
  432. [
  433. AC_MSG_RESULT(yes)
  434. HAVECRYPTO="yes"
  435. ],
  436. [
  437. AC_MSG_RESULT(no)
  438. LDFLAGS="$CLEANLDFLAGS"
  439. CPPFLAGS="$CLEANCPPFLAGS"
  440. LIBS="$CLEANLIBS"
  441. ])
  442. ])
  443. ])
  444. ])
  445. if test X"$HAVECRYPTO" = X"yes"; then
  446. dnl This is only reasonable to do if crypto actually is there: check for
  447. dnl SSL libs NOTE: it is important to do this AFTER the crypto lib
  448. AC_CHECK_LIB(ssl, SSL_connect)
  449. if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
  450. dnl we didn't find the SSL lib, try the RSAglue/rsaref stuff
  451. AC_MSG_CHECKING(for ssl with RSAglue/rsaref libs in use);
  452. OLIBS=$LIBS
  453. LIBS="-lRSAglue -lrsaref $LIBS"
  454. AC_CHECK_LIB(ssl, SSL_connect)
  455. if test "$ac_cv_lib_ssl_SSL_connect" != yes; then
  456. dnl still no SSL_connect
  457. AC_MSG_RESULT(no)
  458. LIBS=$OLIBS
  459. else
  460. AC_MSG_RESULT(yes)
  461. fi
  462. else
  463. dnl Have the libraries--check for OpenSSL headers
  464. AC_CHECK_HEADERS(openssl/x509.h openssl/rsa.h openssl/crypto.h \
  465. openssl/pem.h openssl/ssl.h openssl/err.h,
  466. ssl_msg="OpenSSL"
  467. test openssl != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes
  468. OPENSSL_ENABLED=1
  469. AC_DEFINE(USE_OPENSSL, 1, [if OpenSSL is in use]))
  470. if test $ac_cv_header_openssl_x509_h = no; then
  471. dnl we don't use the "action" part of the AC_CHECK_HEADERS macro
  472. dnl since 'err.h' might in fact find a krb4 header with the same
  473. dnl name
  474. AC_CHECK_HEADERS(x509.h rsa.h crypto.h pem.h ssl.h err.h)
  475. if test $ac_cv_header_x509_h = yes &&
  476. test $ac_cv_header_crypto_h = yes &&
  477. test $ac_cv_header_ssl_h = yes; then
  478. dnl three matches
  479. ssl_msg="OpenSSL"
  480. OPENSSL_ENABLED=1
  481. fi
  482. fi
  483. fi
  484. if test X"$OPENSSL_ENABLED" != X"1"; then
  485. LIBS="$CLEANLIBS"
  486. fi
  487. if test X"$OPT_OPENSSL" != Xoff &&
  488. test "$OPENSSL_ENABLED" != "1"; then
  489. AC_MSG_ERROR([OpenSSL libs and/or directories were not found where specified!])
  490. fi
  491. fi
  492. if test X"$OPENSSL_ENABLED" = X"1"; then
  493. dnl These can only exist if OpenSSL exists
  494. dnl OpenSSL_version is introduced in 3.0.0
  495. AC_CHECK_FUNCS( RAND_egd \
  496. SSLv2_client_method \
  497. OpenSSL_version )
  498. AC_MSG_CHECKING([for BoringSSL])
  499. AC_COMPILE_IFELSE([
  500. AC_LANG_PROGRAM([[
  501. #include <openssl/base.h>
  502. ]],[[
  503. #ifndef OPENSSL_IS_BORINGSSL
  504. #error not boringssl
  505. #endif
  506. ]])
  507. ],[
  508. AC_MSG_RESULT([yes])
  509. AC_DEFINE_UNQUOTED(HAVE_BORINGSSL, 1,
  510. [Define to 1 if using BoringSSL.])
  511. ssl_msg="BoringSSL"
  512. ],[
  513. AC_MSG_RESULT([no])
  514. ])
  515. AC_MSG_CHECKING([for libressl])
  516. AC_COMPILE_IFELSE([
  517. AC_LANG_PROGRAM([[
  518. #include <openssl/opensslv.h>
  519. ]],[[
  520. int dummy = LIBRESSL_VERSION_NUMBER;
  521. ]])
  522. ],[
  523. AC_MSG_RESULT([yes])
  524. AC_DEFINE_UNQUOTED(HAVE_LIBRESSL, 1,
  525. [Define to 1 if using libressl.])
  526. ssl_msg="libressl"
  527. ],[
  528. AC_MSG_RESULT([no])
  529. ])
  530. AC_MSG_CHECKING([for OpenSSL >= v3])
  531. AC_COMPILE_IFELSE([
  532. AC_LANG_PROGRAM([[
  533. #include <openssl/opensslv.h>
  534. ]],[[
  535. #if defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3)
  536. return 0;
  537. #else
  538. #error older than 3
  539. #endif
  540. ]])
  541. ],[
  542. AC_MSG_RESULT([yes])
  543. AC_DEFINE_UNQUOTED(HAVE_OPENSSL3, 1,
  544. [Define to 1 if using OpenSSL 3 or later.])
  545. dnl OpenSSLv3 marks the DES functions deprecated but we have no
  546. dnl replacements (yet) so tell the compiler to not warn for them
  547. dnl
  548. dnl Ask OpenSSL to suppress the warnings.
  549. CPPFLAGS="$CPPFLAGS -DOPENSSL_SUPPRESS_DEPRECATED"
  550. ssl_msg="OpenSSL v3+"
  551. ],[
  552. AC_MSG_RESULT([no])
  553. ])
  554. fi
  555. if test "$OPENSSL_ENABLED" = "1"; then
  556. if test -n "$LIB_OPENSSL"; then
  557. dnl when the ssl shared libs were found in a path that the run-time
  558. dnl linker doesn't search through, we need to add it to CURL_LIBRARY_PATH
  559. dnl to prevent further configure tests to fail due to this
  560. if test "x$cross_compiling" != "xyes"; then
  561. CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$LIB_OPENSSL"
  562. export CURL_LIBRARY_PATH
  563. AC_MSG_NOTICE([Added $LIB_OPENSSL to CURL_LIBRARY_PATH])
  564. fi
  565. fi
  566. CURL_CHECK_OPENSSL_API
  567. check_for_ca_bundle=1
  568. fi
  569. test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg"
  570. fi
  571. if test X"$OPT_OPENSSL" != Xno &&
  572. test "$OPENSSL_ENABLED" != "1"; then
  573. AC_MSG_NOTICE([OPT_OPENSSL: $OPT_OPENSSL])
  574. AC_MSG_NOTICE([OPENSSL_ENABLED: $OPENSSL_ENABLED])
  575. AC_MSG_ERROR([--with-openssl was given but OpenSSL could not be detected])
  576. fi
  577. dnl **********************************************************************
  578. dnl Check for the random seed preferences
  579. dnl **********************************************************************
  580. if test X"$OPENSSL_ENABLED" = X"1"; then
  581. AC_ARG_WITH(egd-socket,
  582. AS_HELP_STRING([--with-egd-socket=FILE],
  583. [Entropy Gathering Daemon socket pathname]),
  584. [ EGD_SOCKET="$withval" ]
  585. )
  586. if test -n "$EGD_SOCKET" ; then
  587. AC_DEFINE_UNQUOTED(EGD_SOCKET, "$EGD_SOCKET",
  588. [your Entropy Gathering Daemon socket pathname] )
  589. fi
  590. dnl Check for user-specified random device
  591. AC_ARG_WITH(random,
  592. AS_HELP_STRING([--with-random=FILE],
  593. [read randomness from FILE (default=/dev/urandom)]),
  594. [ RANDOM_FILE="$withval" ],
  595. [
  596. if test x$cross_compiling != xyes; then
  597. dnl Check for random device
  598. AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
  599. else
  600. AC_MSG_WARN([skipped the /dev/urandom detection when cross-compiling])
  601. fi
  602. ]
  603. )
  604. if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
  605. AC_SUBST(RANDOM_FILE)
  606. AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
  607. [a suitable file to read random data from])
  608. fi
  609. fi
  610. dnl ---
  611. dnl We require OpenSSL with SRP support.
  612. dnl ---
  613. if test "$OPENSSL_ENABLED" = "1"; then
  614. AC_CHECK_LIB(crypto, SRP_Calc_client_key,
  615. [
  616. AC_DEFINE(HAVE_OPENSSL_SRP, 1, [if you have the function SRP_Calc_client_key])
  617. AC_SUBST(HAVE_OPENSSL_SRP, [1])
  618. ])
  619. fi
  620. dnl ---
  621. dnl Whether the OpenSSL configuration will be loaded automatically
  622. dnl ---
  623. if test X"$OPENSSL_ENABLED" = X"1"; then
  624. AC_ARG_ENABLE(openssl-auto-load-config,
  625. AS_HELP_STRING([--enable-openssl-auto-load-config],[Enable automatic loading of OpenSSL configuration])
  626. AS_HELP_STRING([--disable-openssl-auto-load-config],[Disable automatic loading of OpenSSL configuration]),
  627. [ if test X"$enableval" = X"no"; then
  628. AC_MSG_NOTICE([automatic loading of OpenSSL configuration disabled])
  629. AC_DEFINE(CURL_DISABLE_OPENSSL_AUTO_LOAD_CONFIG, 1, [if the OpenSSL configuration won't be loaded automatically])
  630. fi
  631. ])
  632. fi
  633. ])