4656 Commits

Author SHA1 Message Date
Azat Khuzhin
d84c88519d test: suppress warning for already defined SSL_get_peer_certificate
build report:

    [1/2] Building C object CMakeFiles/regress.dir/test/regress_mbedtls.c.o
    /src/le/libevent/test/regress_mbedtls.c:50: warning: "SSL_get_peer_certificate" redefined
       50 | #define SSL_get_peer_certificate mbedtls_ssl_get_peer_cert
          |
    In file included from /src/le/libevent/test/regress.h:139,
                     from /src/le/libevent/test/regress_mbedtls.c:35:
    /src/oss/openssl/include/openssl/ssl.h:1799: note: this is the location of the previous definition
     1799 | #   define SSL_get_peer_certificate SSL_get1_peer_certificate
          |
    [2/2] Linking C executable bin/regress

But this should be cleaned up.
2022-07-10 10:07:39 +03:00
Azat Khuzhin
a0087e2c7a autotools: print $OPENSSL_LIBS/$OPENSSL_INCS 2022-07-10 10:07:39 +03:00
Azat Khuzhin
e67085e56e Suppress -Wunused-value for BIO_set_close() 2022-07-10 10:07:39 +03:00
Azat Khuzhin
c22f275744 Use OPENSSL_VERSION_NUMBER over OPENSSL_VERSION_MAJOR (for compatibility)
Since OpenSSL 3.0 there is new OPENSSL_VERSION_MAJOR, but previous
releases does not have it.

So let's use plain old OPENSSL_VERSION_NUMBER to avoid more preprocessor
macros.
2022-07-10 10:07:39 +03:00
William Marlow
a29570a1e2 Attempt to add OpenSSL 3 to the Linux build matrix
v2: fix echo messages
v3: fix autotools build (wrong path to pkg config)
2022-07-10 10:07:25 +03:00
William Marlow
29c420c418 Initial OpenSSL 3.0 support
* Don't use deprecated functions when building against OpenSSL 3.0.
* Recognise that OpenSSL 3.0 can signal a dirty shutdown as a protocol.
  error in addition to the expected IO error produced by OpenSSL 1.1.1
* Update regress_mbedtls.c for compatibility with OpenSSL 3
2022-07-09 23:24:53 +03:00
Azat Khuzhin
20977eae0d Merge branch 'mbedtls-3'
* mbedtls-3:
  sample/ssl-client-mbedtls.c: fix for MbedTLS 3
  sample/ssl-client-mbedtls.c: break the loop on EOF
  sample/ssl-client-mbedtls.c: fix printing response in readcb
  Initial Mbed-TLS 3 support to get the GitHub Actions working again
  Support build dir of the MbedTLS
2022-07-09 23:22:00 +03:00
Azat Khuzhin
acb7ef9819 ci/macos: remove separate openssl 1.1 from build matrix
@ploxiln:

    On current homebrew, openssl@1.1 is the only openssl:

    [pierce@plo-mbp15 libevent]$ brew --prefix openssl
    /usr/local/opt/openssl@1.1
    [pierce@plo-mbp15 libevent]$ brew info openssl
    openssl@1.1: stable 1.1.1g (bottled) [keg-only]
    Cryptography and SSL/TLS Toolkit

@fanquake

    Indeed. OpenSSL 1.0 was removed from homebew in Homebrew/homebrew-core#46876. Related discussion also in Homebrew/homebrew-core#46454.
2022-07-09 21:17:06 +03:00
Azat Khuzhin
8bcbec77dd Merge branch 'fix-brew-autodetection'
* fix-brew-autodetection:
  ci: fix cmake build w/o OPENSSL_ROOT_DIR
  ci: remove separate build for BREW_AUTODETECT_OPENSSL (use it by default)
  autotools: fix autodetection of openssl location via brew
2022-07-09 21:14:16 +03:00
Azat Khuzhin
6e310e3c6c sample/ssl-client-mbedtls.c: fix for MbedTLS 3
- use build_info.h over version.h
- provide own certs

P.S. since it is simpler then adding detection of the library version
into autotools.
2022-07-09 21:11:29 +03:00
Azat Khuzhin
ce20356a32 sample/ssl-client-mbedtls.c: break the loop on EOF 2022-07-09 21:07:49 +03:00
Azat Khuzhin
fcf85e4822 sample/ssl-client-mbedtls.c: fix printing response in readcb 2022-07-09 21:07:49 +03:00
William Marlow
384c52e6be Initial Mbed-TLS 3 support to get the GitHub Actions working again
mingw has upgraded to Mbed-TLS 3.1.0, so all the mingw tests that need
Mbed-TLS currently don't work.

v2: add missing mbedtls/version.h into test/regress_mbedtls.c
v3: suppress #warning "Including compat-2.x.h is deprecated" for mbedtls/compat-2.x.h
2022-07-09 20:47:04 +03:00
Azat Khuzhin
35e12a8175 Support build dir of the MbedTLS 2022-07-09 20:47:04 +03:00
Azat Khuzhin
d881d06260 configure: fix AC_CHECK_FUNCS should use literals
Error

    configure.ac:291: warning: AC_CHECK_FUNCS(getnameinfo
    ): you should use literals
    ../autoconf-2.71/lib/autoconf/functions.m4:117: AC_CHECK_FUNCS is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
    configure.ac:291: the top level
    configure.ac:291: warning: AC_CHECK_FUNCS(getprotobynumber
    ): you should use literals
    ../autoconf-2.71/lib/autoconf/functions.m4:117: AC_CHECK_FUNCS is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
    configure.ac:291: the top level
    configure.ac:291: warning: AC_CHECK_FUNCS(getservbyname
    ): you should use literals
    ../autoconf-2.71/lib/autoconf/functions.m4:117: AC_CHECK_FUNCS is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
    configure.ac:291: the top level
    configure.ac:291: warning: AC_CHECK_FUNCS(inet_ntop
    ): you should use literals
    ../autoconf-2.71/lib/autoconf/functions.m4:117: AC_CHECK_FUNCS is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
    configure.ac:291: the top level
    configure.ac:291: warning: AC_CHECK_FUNCS(inet_pton
    ): you should use literals
    ../autoconf-2.71/lib/autoconf/functions.m4:117: AC_CHECK_FUNCS is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
    ../autoconf-2.71/lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
    configure.ac:291: the top level
2022-07-09 20:29:09 +03:00
kenping
d96457e132 listener: Preserve last error in evconnlistener_new_bind() before close
In function evconnlistener_new_bind() after go to "err:", The
evutil_closesocket() would clear the error code( I found this under
Windows ). User can not use EVUTIL_SOCKET_ERROR() to get the
evconnlistener_new_bind()'s failing error.

I add a err_code variable to store and restore the last error code.

v2: rebased by azat to make the patch simpler
2022-07-09 20:20:58 +03:00
Azat Khuzhin
a9441ed646 ci: fix cmake build w/o OPENSSL_ROOT_DIR
cmake build rules does not have detection of OPENSSL_ROOT_DIR via brew,
so we cannot run such builds on CI.

Always set OPENSSL_ROOT_DIR for cmake.
2022-07-09 20:15:17 +03:00
Azat Khuzhin
4954b27bc0 ci: remove separate build for BREW_AUTODETECT_OPENSSL (use it by default) 2022-07-09 20:15:17 +03:00
Azat Khuzhin
8bad28d607 autotools: fix autodetection of openssl location via brew 2022-07-09 20:15:17 +03:00
Azat Khuzhin
7aeecb60c4 Merge branch 'Werror'
* Werror:
  test: ignore -Walloc-size-larger-than error for calloc() returns ENOMEM
  Fix EVBASE_ACQUIRE_LOCK/EVBASE_RELEASE_LOCK for EVENT__DISABLE_THREAD_SUPPORT
  http: suppress "flags may be used uninitialized in this function" error
  Detech -Wno-unused-functions for GCC too
  cmake: add compiler version to the status message
  Fix BEV_LOCK/BEV_UNLOCK macros for EVENT__DISABLE_THREAD_SUPPORT
  Run builds with -Werror on CI for linux
  Fix -Werror for autotools
  Add -Wundef for cmake and fix EVENT__SIZEOF_TIME_T usage
2022-07-09 18:12:07 +03:00
Azat Khuzhin
8933217698 test: ignore -Walloc-size-larger-than error for calloc() returns ENOMEM
Compiler report:

    /home/runner/work/libevent/libevent/test/regress_util.c: In function ‘test_event_calloc’:
    /home/runner/work/libevent/libevent/test/regress_util.c:1318:4: error: argument 2 value ‘9223372036854775815’ exceeds maximum object size 9223372036854775807 [-Werror=alloc-size-larger-than=]
      p = mm_calloc(EV_SIZE_MAX/2, EV_SIZE_MAX/2 + 8);
    In file included from /home/runner/work/libevent/libevent/test/../util-internal.h:37:0,
                     from /home/runner/work/libevent/libevent/test/regress_util.c:30:
    /usr/include/stdlib.h:541:14: note: in a call to allocation function ‘calloc’ declared here
     extern void *calloc (size_t __nmemb, size_t __size)

v2: clang on CI does not have this option
2022-07-09 17:36:13 +03:00
Azat Khuzhin
648af99afa Fix EVBASE_ACQUIRE_LOCK/EVBASE_RELEASE_LOCK for EVENT__DISABLE_THREAD_SUPPORT 2022-07-09 17:36:13 +03:00
Azat Khuzhin
c8501afc0c http: suppress "flags may be used uninitialized in this function" error
Some GCC reports [1]:

    /home/runner/work/libevent/libevent/http.c: In function ‘evhttp_make_header’:
    /home/runner/work/libevent/libevent/http.c:503:14: error: ‘flags’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
      ev_uint16_t flags;
                  ^~~~~
    /home/runner/work/libevent/libevent/http.c: In function ‘evhttp_get_body’:
    /home/runner/work/libevent/libevent/http.c:2354:14: error: ‘flags’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
      ev_uint16_t flags;
                  ^~~~~
  [1]: https://github.com/libevent/libevent/runs/7263518338?check_suite_focus=true#logs
2022-07-09 17:36:13 +03:00
Azat Khuzhin
3960449374 Detech -Wno-unused-functions for GCC too
Otherwise build fails [1]:

    /home/runner/work/libevent/libevent/dist/libevent-2.2.0-alpha-dev/minheap-internal.h:64:6: error: ‘min_heap_ctor_’ defined but not used [-Werror=unused-function]
     void min_heap_ctor_(min_heap_t* s) { s->p = 0; s->n = 0; s->a = 0; }
          ^~~~~~~~~~~~~~
    In file included from /home/runner/work/libevent/libevent/dist/libevent-2.2.0-alpha-dev/buffer.c:91:0:
    /home/runner/work/libevent/libevent/dist/libevent-2.2.0-alpha-dev/bufferevent-internal.h:414:1: error: ‘bufferevent_trigger_nolock_’ defined but not used [-Werror=unused-function]
     bufferevent_trigger_nolock_(struct bufferevent *bufev, short iotype, int options)
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from /home/runner/work/libevent/libevent/dist/libevent-2.2.0-alpha-dev/buffer.c:89:0:
    /home/runner/work/libevent/libevent/dist/libevent-2.2.0-alpha-dev/evthread-internal.h:140:1: error: ‘EVLOCK_TRY_LOCK_’ defined but not used [-Werror=unused-function]
     EVLOCK_TRY_LOCK_(void *lock)

  [1]: https://github.com/libevent/libevent/runs/7263518180?check_suite_focus=true
2022-07-09 17:17:06 +03:00
Azat Khuzhin
92b73c7d55 cmake: add compiler version to the status message 2022-07-09 17:17:06 +03:00
Azat Khuzhin
0955071470 Fix BEV_LOCK/BEV_UNLOCK macros for EVENT__DISABLE_THREAD_SUPPORT 2022-07-09 17:17:06 +03:00
Azat Khuzhin
1915b564f3 Run builds with -Werror on CI for linux 2022-07-09 17:17:04 +03:00
Azat Khuzhin
039458892b Fix -Werror for autotools 2022-07-09 17:16:56 +03:00
Azat Khuzhin
f5ad737d73 Add -Wundef for cmake and fix EVENT__SIZEOF_TIME_T usage
Note, autotools already supports it.
2022-07-09 17:16:56 +03:00
Azat Khuzhin
1bc62ce171 https-client: fix strndup() for mingw build
Right now it still reports [1]:

    2022-07-09T10:53:05.4152800Z ../sample/https-client.c:558:43: warning: implicit declaration of function 'strndup' [-Wimplicit-function-declaration]
    2022-07-09T10:53:05.4153300Z   558 |                         char *host_ipv6 = strndup(&host[1], strlen(&host[1]) - 1);
    2022-07-09T10:53:05.4153651Z       |                                           ^~~~~~~
    2022-07-09T10:53:05.4154095Z ../sample/https-client.c:558:43: warning: incompatible implicit declaration of built-in function 'strndup' [-Wbuiltin-declaration-

  [1]: https://github.com/libevent/libevent/runs/7263194178?check_suite_focus=true
2022-07-09 14:39:32 +03:00
Azat Khuzhin
29032da661 Fix some OpenSSL 3 test issues (#1291)
These are updates to help with OpenSSL 3 compilation. I found
https://github.com/libevent/libevent/pull/1288 after I started this, but
these seem independent, and fix a different set of problems:

- First off, OpenSSL 3 does not by default allow signing with SHA1
  digests - moving this to SHA256 universally at this point seems a
  better idea than continuing to use the insecure SHA1 for older OpenSSL
  versions. This fixes X509_sign failing in regress_openssl for a number
  of tests, eg:

  ```
   regress: http/https_openssl_basic:
    FAIL ../test/regress_openssl.c:106: assert(0 != X509_sign(x509, key, EVP_sha1()))[Lost connection!] http/https_openssl_filter_basic:
    FAIL ../test/regress_openssl.c:106: assert(0 != X509_sign(x509, key, EVP_sha1()))[Lost connection!] http/https_openssl_simple:
  ...
  ```

- Secondly, when using TLS 1.3, there's no support for renegotiation, so
  for the renegotiation tests, we need to disable TLS v1.3, and expect
  to negotiate TLS 1.1 or 1.2

Fixes: #661

* upstream/pr/1291:
  OpenSSL 3 fixes: Disable TLS 1.3 when testing renegotiation support
  OpenSSL 3 fixes: use SHA256 instead of SHA1
2022-07-09 13:37:25 +03:00
William Marlow
e43376df2a Add missing strndup function on Windows to fix build on MSVC 2022
v2: Only define strndup on non-Mingw32 Windows
2022-07-09 13:16:00 +03:00
fanquake
bf3ce77f6c build: only try silence options if they exist
Otherwise GCC will warn. i.e:
```bash
  CCLD     libevent_openssl.la
cc1: note: unrecognized command-line option ‘-Wno-void-pointer-to-enum-cast’
	may have been intended to silence earlier diagnostics
  CCLD     libevent_mbedtls.la
```
2022-06-30 22:06:51 +03:00
Peter Edwards
187f6b913b OpenSSL 3 fixes: Disable TLS 1.3 when testing renegotiation support
TLS 1.3 does not support renegotation - it has been removed from the
protocol. Disable TLS 1.3 when testing this, so we negotiate an older
protocol version
2022-06-27 23:10:15 +01:00
Peter Edwards
e563c9b206 OpenSSL 3 fixes: use SHA256 instead of SHA1
OpenSSL 3.x does not support signing certificates with SHA1 by default.
Use SHA256 instead.
2022-06-27 23:07:58 +01:00
cui fliter
1c204d5564
Fix some typos (#1284)
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-06-12 23:58:50 +03:00
Azat Khuzhin
41239c9dac https-client: fix connect to ipv6 address with square brackets
getaddrinfo() cannot process addresses like "[::1]", only "::1"

Fixes: #1275
2022-05-12 07:37:19 +03:00
zhongzedu
5cc2ff8897 fix grammar in comment 2022-05-12 15:00:52 +03:00
Syedh30
e339880f55 include/event.h: include <event2/util.h> over deprecatd <evutil.h>
Fixes: #1263
2022-04-30 02:32:13 +03:00
Igor Klemenski
21e2862689 Fix mingw pipeline (by using correct PATH to msys64)
I found the correct path by looking at the _Disable Key Refresh_ step in
_mingw::autotools::set up msys2_ task
(https://github.com/rectified95/libevent/runs/5858227589?check_suite_focus=true)

    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe "((Get-Content -path **D:\a\_temp\msys64**\etc\post-install\07-pacman-key.post -Raw) ...
2022-04-07 08:32:09 +03:00
Igor Klemenski
097ff9a433 Fix windows pipeline (by updating vcpkg version to latest)
The Windows CI is failing at the prepare vcpkg step while installing zlib
Changing the vcpkg commit hash to point to latest release
https://github.com/microsoft/vcpkg/releases/tag/2022.03.10 as opposed to
sometime in 2019 to see if that fixes it.
2022-04-07 08:27:56 +03:00
moonlightsh
66861f8891 Require libevent_core not libevent for pkg-config
libevent library itself had been deprecated long time ago.

Fixes: #1213
2022-03-11 08:13:56 +03:00
Azat Khuzhin
6349e94a0a Do not install RPATH for install tree by default
In ce8be2385b5fee16859a630fca0c98ad290c8e21 ("cmake: set rpath for
libraries on linux") RPATH was first instroduced.

Later in 6d09efe8686de824adf3d8810bbe0d5c386643e4 ("Set RPATH only if
installation is done into non system directory") it was set only if it
was installed to non system directory.

But absolute RPATH not a good default, let's change this.

Fixes: #920
2022-03-10 23:54:58 +03:00
Jay Freeman (saurik)
3da71856a7 Fix build w/o OpenSSL by w/ MbedTLS
In 78fa3971be892194aa168c04fc34bf5f2cd99b99 from
https://github.com/libevent/libevent/pull/1241#commitcomment-63865496 a
new "if MBEDTLS" block was added to include/include.am. This is not
parsed by automake as it isn't on the first column, resulting in a
subsequent error in the build.

From [1]:

> The if, else, and endif statements should not be indented, i.e., start on column one.

  [1]: https://www.gnu.org/software/automake/manual/html_node/Usage-of-Conditionals.html

Fixes: #1251
Fixes: google/oss-fuzz#7149
2022-02-12 22:57:30 +03:00
Azat Khuzhin
6d09efe868 Set RPATH only if installation is done into non system directory
v2: use CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES

Fixes: #1245
2022-01-15 22:10:36 +03:00
Dmitry Ilyin
78fa3971be Fix make install failed when Automake used and both OpenSSL and MbedTLS are activated
Issue:
https://github.com/libevent/libevent/pull/1241#commitcomment-63865496
2022-01-15 08:30:26 +03:00
Jessica Clarke
a9595ccd7d regress_ssl: Use intptr_t when shoving an int into a void *
Currently the code uses long, but long does not always have the same
representation as a pointer, such as on 64-bit Windows where long is
only 32-bit due to its unususal LLP64 ABI, but also on CHERI, and thus
Arm's prototype Morello architecture, where C language pointers are
represented as hardware capabilities, which have bounds, permissions and
other metadata to enforce spatial memory safety. Both of these cases
warn when casting a long to a pointer (Windows due to long being shorter
and thus it being likely you've truncated the address, and CHERI due to
long not having any capability metadata like pointers and thus it being
likely you've stripped the metadata, with the resulting "null-derived"
capability destined to trap if dereferenced), and in both cases casting
to intptr_t as the intermediate type instead will get rid of those
warnings.
2021-12-21 13:15:58 +00:00
Azat Khuzhin
09e9fed2bd test: fix leak in http/cancel_*server_timeout tests
Fixes: #1242
2021-12-21 08:47:00 +03:00
Dmitry Ilyin
2db55e43cf Install bufferevent_ssl.h with MbedTLS support also 2021-12-15 21:27:21 +03:00
Yongsheng Xu
cd6a41ecdd feat: add evdns_base_get_nameserver_fd method
To get underlying udp socket fd.
2021-12-10 11:05:13 +08:00