Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync with upstream 1.8.0 #234

Merged
merged 44 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
5e99885
add header to posix_rand_getrandom.c
shikokuchuo Apr 11, 2024
14a1bc5
Add missing `nng_tls_config_hold` stub function
mlasch Apr 8, 2024
073be17
Added realtime clock support, and better timestamping.
gdamore Apr 14, 2024
6ba5944
* MDF [TEST] remove NUTS_ENABLE_LOG
JaylinYu Jul 29, 2024
cdbf393
[tls_common] finish conn lock in tls_reap
RanMaoyi Apr 15, 2024
8ed5162
Bump golang.org/x/net from 0.19.0 to 0.23.0 in /etc/pubrefman
dependabot[bot] Apr 19, 2024
b8c83fa
Prep for 1.8.0 release
gdamore Apr 21, 2024
ea3e476
Move some supplemental APIs to reduce friction in using them.
gdamore Apr 23, 2024
cd08868
Move the rest of the functionality from platform.h into core.
gdamore Apr 23, 2024
005a9e3
fixes #1808 nng_msg_insert: munmap_chunk(): invalid pointer
gdamore Apr 24, 2024
fbd5bba
fix deadlock on socket close
alzix Apr 24, 2024
4bf3d43
Windows: add a check for broken legacy environments without timespec_…
gdamore May 22, 2024
4f29568
fixes #1825 Compiler warning due to unused variable in win_clock.c
gdamore May 22, 2024
371d452
fixes #1827 Windows a deadlock on nng_close()
gdamore Apr 25, 2024
27d74f6
Another attempt at the close deadlock, fix use-after-free.
gdamore Apr 27, 2024
9f87dca
windows: IPC conn->conn_io is unused
gdamore May 22, 2024
efc0f5e
windows: drop the hEvent initialization for win_io structures.
gdamore May 26, 2024
5a6a451
windows: fix TCP use-after-free in listener
gdamore May 26, 2024
5b1212d
windows: ipc conn conn_aio not used
gdamore May 26, 2024
e1228ea
windows: ipc listen use after free
gdamore May 27, 2024
5ca4e40
windows: TCP connection use-after-free fixes
gdamore May 27, 2024
cdb3faa
fix for pipe statistic crash
gdamore May 26, 2024
d8557ab
Safer initialization of aios
gdamore May 28, 2024
e9623b5
Free SP protocol streams before discarding aio objects.
gdamore May 28, 2024
ecf4231
windows: refactor IPC to avoid possible hangs and use after free.
gdamore May 28, 2024
8e2a201
Fixes problem that causing it unable to pass compile when NNG_TRANSPO…
PWisPeterWang Apr 30, 2024
b279bb9
UDP: Introduce an experimental (undocumented for now) public API for …
gdamore Jun 3, 2024
7b21850
fix testcase crash on NUTTX When log_buf is null for the first time. …
Meissi-jian Jul 16, 2024
b11d31c
fixes #1835 setting NNG_OPT_TLS_CONFIG on socket should hold reference
gdamore Jul 21, 2024
e8bd421
fixes #1846 Add support for TLS PSK
gdamore Jul 20, 2024
83b0cfc
Bump CodeQL to v2
gdamore Jul 21, 2024
75f58f9
Fix conditional tls_tran_test
gdamore Jul 21, 2024
709a835
TLS: announce which engine we are using (in anticipation of newer TLS…
gdamore Jul 23, 2024
42a1122
Bump minimum CMake version to 3.15
gdamore Jul 23, 2024
413baef
TLS: Stop making the licensing message a warning - notice is sufficient.
gdamore Jul 23, 2024
cf2b3b6
TLS: make some tests conditional.
gdamore Jul 23, 2024
dc91a0b
fixes #1849 merge wolfSSL support inline, and relicense it under same…
gdamore Jul 23, 2024
42167e7
Drop the external submodule. It isn't needed anymore.
gdamore Jul 23, 2024
c36d5f7
Add WolfSSL building information
gdamore Jul 23, 2024
efa9c1d
* FIX [transport/mqtt] fix UAF in transport, according to upstream
JaylinYu Jul 29, 2024
a072a7f
* RM nng log
JaylinYu Jul 29, 2024
51d149f
fix sync error
JaylinYu Jul 29, 2024
3681c75
* MDF [tls] fix sync error
JaylinYu Jul 29, 2024
5f1a1e3
* ADD missing certs for nng testing
JaylinYu Jul 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 30 additions & 30 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ name: "CodeQL"

on:
push:
branches: [ master ]
branches: [master]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
branches: [master]
schedule:
- cron: '27 2 * * 2'
- cron: "27 2 * * 2"

jobs:
analyze:
Expand All @@ -32,41 +32,41 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]
language: ["cpp"]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
queries: +security-and-quality
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
queries: +security-and-quality
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release
#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "extern/nng-wolfssl"]
path = extern/nng-wolfssl
url = https://github.com/staysail/nng-wolfssl
[submodule "extern/msquic"]
path = extern/msquic
url = https://github.com/microsoft/msquic.git
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# IN THE SOFTWARE.
#

cmake_minimum_required(VERSION 3.13)
cmake_minimum_required(VERSION 3.15)

project(nng C)
include(CheckCCompilerFlag)
Expand Down
66 changes: 66 additions & 0 deletions cmake/FindwolfSSL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#
# Copyright 2024 Staysail Systems, Inc. <[email protected]>
#
# This software is supplied under the terms of the MIT License, a
# copy of which should be located in the distribution where this
# file was obtained (LICENSE.txt). A copy of the license may also be
# found online at https://opensource.org/licenses/MIT.
#

#
# Try to find the wolfSSL library. We only support modern wolfSSL,
# not the older CyaSSL.
#
# Sets the following:
#
# WOLFSSL_INCLUDE_DIR - Where to find wolfssl/ssl.h, etc.
# WOLFSSL_FOUND - True if we found wolfSSL.
# WOLFSSL_LIBRARIES - The wolfSSL library (libwolfssl).
# WOLFSSL_LIBRARY - The wolfSSL library (libwolfssl).
# WOLFSSL_VERSION - $major.$minor.$revision (e.g. ``3.13.0``).
#
# Adds wolfSSL::wolfssl target for the library.
#
# Hints:
#
# Set ``WOLFSSL_ROOT_DIR`` to the root directory of wolfSSL installation.
#

set(_WOLFSSL_ROOT_HINTS ${WOLFSSL_ROOT_DIR} ENV WOLFSSL_ROOT_DIR)

include(FindPackageHandleStandardArgs)
include(CMakePushCheckState)

find_path(WOLFSSL_INCLUDE_DIR
NAMES wolfssl/ssl.h
HINTS ${_WOLFSSL_ROOT_HINTS}
PATHS /usr/local
PATH_SUFFIXES include)

find_library(WOLFSSL_LIBRARY
NAMES wolfssl
HINTS ${_WOLFSSL_ROOT_HINTS}
PATHS /usr/local
PATH_SUFFIXES lib)

set(WOLFSSL_LIBRARIES ${WOLFSSL_LIBRARY})
if (${WOLFSSL_LIBRARY-NOTFOUND})
message(FATAL_ERROR "Failed to find wolfSSL library")
endif()

mark_as_advanced(WOLFSSL_INCLUDE_DIR WOLFSSL_LIBRARY)

# Extract the version from the header... hopefully it matches the library.
file(STRINGS ${WOLFSSL_INCLUDE_DIR}/wolfssl/version.h _WOLFSSL_VERLINE
REGEX "^#define[ \t]+LIBWOLFSSL_VERSION_STRING[\t ].*")
string(REGEX REPLACE ".*WOLFSSL_VERSION_STRING[\t ]+\"(.*)\"" "\\1" WOLFSSL_VERSION ${_WOLFSSL_VERLINE})

add_library(wolfSSL::wolfssl UNKNOWN IMPORTED)

set_target_properties(wolfSSL::wolfssl PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${WOLFSSL_INCLUDE_DIR}")
set_target_properties(wolfSSL::wolfssl PROPERTIES IMPORTED_LOCATION "${WOLFSSL_LIBRARY}")

set(wolfSSL_TARGET wolfssl::wolfssl)

find_package_handle_standard_args(wolfSSL
REQUIRED_VARS WOLFSSL_LIBRARY WOLFSSL_INCLUDE_DIR VERSION_VAR WOLFSSL_VERSION)
72 changes: 0 additions & 72 deletions docs/BUILD_TLS.adoc

This file was deleted.

80 changes: 80 additions & 0 deletions docs/BUILD_TLS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Building for TLS Support

If you want to include support for Transport Layer Security
(`tls+tcp://` and `wss://` URLs) you should follow these directions.

TLS support in NNG depends on either the [Mbed TLS](https://tls.mbed.org/)
or [WolfSSL](https://www.wolfssl.com/) library (your choice).

> [!IMPORTANT]
> These libraries are licensed under different terms than NNG.
> You are responsible for reading those license terms, and ensuring
> that your use conforms to them.

> [!TIP]
> This project receives no compensation or support in any other form
> from either ARM (owners of the Mbed TLS project) or WolfSSL.
> Thus, as a special request, if you're paying for commercial licenses for
> either Mbed TLS or WolfSSL for use with NNG, please consider also sponsoring
> this project or obtaining a commercial support contract from
> [Staysail Systems, Inc.](https://www.staysail.tech/)
> You can enquire about support contracts at [email protected].
> Sponsorship information is available on our
> [GitHub page](https://github.com/nanomsg/nng). Thank you!

On many distributions you may be able to install a pre-packaged version
of either library. We recommend doing so if this is an option for you.
For example, Ubuntu users can install the `libmbedtls-dev` package.

You can also build these from source; if you choose to do so,
please make sure you also _install_ it somewhere (even a temporary
staging directory).

## Configuring NNG with TLS

TLS support is not enabled by default, but can be enabled by configuring
with the CMake option `NNG_ENABLE_TLS=ON`.

You can select which library to use by using `NNG_TLS_ENGINE=mbed` or
`NNG_TLS_ENGINE=wolf`. If you specify neither, then Mbed TLS will be assumed
by default.

By default NNG searches for an installed components in `/usr/local`,
as well as the normal installation directories for libraries on your system.

If you have installed Mbed TLS elsewhere, you can direct the NNG configuration
to it by setting the `MBEDTLS_ROOT_DIR` or `WOLFSSL_ROOT_DIR` CMake variable
as appropriate.

## Example

The following example would work on either Linux or macOS, and assumes
that we have checked out github source trees into `$HOME/work`.
It also assumes that Mbed TLS is already installed in `/usr/local` or
a standard search path.

```

$ export NNGDIR=$HOME/work/nng
$ mkdir build
$ cd build

$ cmake -G Ninja -DNNG_ENABLE_TLS=ON ..

... (lots of lines of output from cmake...)

$ ninja build

... (lots of lines of output from ninja...)

$ ./src/supplemental/tls/tls_test -v

... (lots of lines of output from the test ...)

Summary:
Count of all unit tests: 9
Count of run unit tests: 9
Count of failed unit tests: 0
Count of skipped unit tests: 0
SUCCESS: All unit tests have passed.
```
1 change: 1 addition & 0 deletions docs/man/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ if (NNG_ENABLE_DOC)
nng_tls_config_free
nng_tls_config_hold
nng_tls_config_own_cert
nng_tls_config_psk
nng_tls_config_server_name
nng_tls_engine_description
nng_tls_engine_fips_mode
Expand Down
3 changes: 2 additions & 1 deletion docs/man/libnng.3.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
= libnng(3)
//
// Copyright 2023 Staysail Systems, Inc. <[email protected]>
// Copyright 2024 Staysail Systems, Inc. <[email protected]>
// Copyright 2018 Capitar IT Group BV <[email protected]>
// Copyright 2019 Devolutions <[email protected]>
// Copyright 2020 Dirac Research <[email protected]>
Expand Down Expand Up @@ -461,6 +461,7 @@ with TLS support.
|xref:nng_tls_config_ca_chain.3tls.adoc[nng_tls_config_ca_chain()]|set certificate authority chain
|xref:nng_tls_config_ca_file.3tls.adoc[nng_tls_config_ca_file()]|load certificate authority from file
|xref:nng_tls_config_cert_key_file.3tls.adoc[nng_tls_config_cert_key_file()]|load own certificate and key from file
|xref:nng_tls_config_psk.3tls.adoc[nng_tls_config_psk()]|set pre-shared key and identity
|xref:nng_tls_config_own_cert.3tls.adoc[nng_tls_config_own_cert()]|set own certificate and key
|xref:nng_tls_config_free.3tls.adoc[nng_tls_config_free()]|free TLS configuration
|xref:nng_tls_config_server_name.3tls.adoc[nng_tls_config_server_name()]|set remote server name
Expand Down
6 changes: 2 additions & 4 deletions docs/man/nng_clock.3supp.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
= nng_clock(3supp)
//
// Copyright 2018 Staysail Systems, Inc. <[email protected]>
// Copyright 2024 Staysail Systems, Inc. <[email protected]>
// Copyright 2018 Capitar IT Group BV <[email protected]>
//
// This document is supplied under the terms of the MIT License, a
Expand All @@ -18,7 +18,6 @@ nng_clock - get time
[source, c]
----
#include <nng/nng.h>
#include <nng/supplemental/util/platform.h>

typedef uint64_t nng_time;

Expand All @@ -37,8 +36,7 @@ very fine-grained values.
IMPORTANT: The reference time will be the same for a given program,
but different programs may have different references.

TIP: This function is intended mostly to help with setting appropriate
timeouts using xref:nng_cv_until.3supp.adoc[`nng_cv_until()`].
TIP: This function should help with setting appropriate timeouts.

== RETURN VALUES

Expand Down
3 changes: 1 addition & 2 deletions docs/man/nng_cv_alloc.3supp.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
= nng_cv_alloc(3supp)
//
// Copyright 2018 Staysail Systems, Inc. <[email protected]>
// Copyright 2024 Staysail Systems, Inc. <[email protected]>
// Copyright 2018 Capitar IT Group BV <[email protected]>
//
// This document is supplied under the terms of the MIT License, a
Expand All @@ -18,7 +18,6 @@ nng_cv_alloc - allocate condition variable
[source, c]
----
#include <nng/nng.h>
#include <nng/supplemental/util/platform.h>

typedef struct nng_cv nng_cv;

Expand Down
Loading
Loading