Skip to content

Commit 0a3107f

Browse files
authored
Merge pull request #300 from qzhuyan/dev/william/prepare-link-system-crypto
prepare link system crypto
2 parents 706fe1c + 88f7507 commit 0a3107f

13 files changed

+65
-27
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ jobs:
9393
openssl:
9494
- openssl3
9595
- openssl
96+
- sys
9697
rebar3:
9798
- 3.23.0
9899
build_type:
@@ -115,15 +116,15 @@ jobs:
115116
- name: release build with debug log off
116117
env:
117118
CMAKE_BUILD_TYPE: ${{ matrix.build_type }}
118-
QUIC_TLS: ${{ matrix.openssl }}
119+
QUICER_TLS_VER: ${{ matrix.openssl }}
119120
QUIC_ENABLE_LOGGING: ${{ matrix.logging }}
120121
run: |
121122
echo "github ref: ${{ github.event.ref }}"
122123
echo "github ref: ${{ github.ref }}"
123124
sudo sysctl -w kernel.core_pattern=core
124125
ulimit -c unlimited
125126
export CMAKE_BUILD_TYPE
126-
export QUIC_TLS
127+
export QUICER_TLS_VER
127128
export QUIC_ENABLE_LOGGING
128129
if [ "${QUIC_ENABLE_LOGGING}" == "ON" ] ; then
129130
export QUIC_LOGGING_TYPE=lttng

.github/workflows/release.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ jobs:
4949
- name: build release
5050
if: startsWith(github.ref, 'refs/tags/')
5151
env:
52-
QUIC_TLS: ${{ matrix.openssl }}
52+
QUICER_TLS_VER: ${{ matrix.openssl }}
5353
run: |
5454
wget https://s3.amazonaws.com/rebar3/rebar3 && chmod +x rebar3
5555
sudo mv rebar3 /usr/local/bin/ && sudo chmod +x /usr/local/bin/rebar3
5656
erl -eval 'erlang:display(erlang:system_info(system_version)),halt()'
57-
export QUIC_TLS
57+
export QUICER_TLS_VER
5858
BUILD_RELEASE=1 make
5959
6060
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
@@ -65,7 +65,7 @@ jobs:
6565
_packages/*.gz
6666
_packages/*.gz.sha256
6767
68-
linux:
68+
emqx-linux:
6969
strategy:
7070
fail-fast: false
7171
matrix:
@@ -75,6 +75,7 @@ jobs:
7575
openssl:
7676
- openssl3
7777
- openssl
78+
- sys
7879
arch:
7980
- amd64
8081
- arm64
@@ -90,6 +91,9 @@ jobs:
9091
- amzn2
9192
- el9
9293
- el8
94+
exclude:
95+
- os: el9
96+
openssl: sys
9397
runs-on: ubuntu-latest
9498

9599
steps:
@@ -113,7 +117,7 @@ jobs:
113117
run: |
114118
IMAGE=ghcr.io/emqx/emqx-builder/5.3-13:1.15.7-${{ matrix.otp }}-${{ matrix.os }}
115119
docker run -i --rm -v $(pwd):/wd --workdir /wd --platform=linux/${{ matrix.arch }} \
116-
-e BUILD_RELEASE=1 -e QUIC_TLS=${{ matrix.openssl }} \
120+
-e BUILD_RELEASE=1 -e QUICER_TLS_VER=${{ matrix.openssl }} \
117121
$IMAGE bash -euc 'git config --global --add safe.directory /wd; make'
118122
119123
- uses: actions/upload-artifact@v4
@@ -128,7 +132,7 @@ jobs:
128132
runs-on: ubuntu-latest
129133
needs:
130134
- mac
131-
- linux
135+
- emqx-linux
132136
if: startsWith(github.ref, 'refs/tags/')
133137
steps:
134138
- uses: actions/download-artifact@v4

CMakeLists.txt

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,20 @@ else()
3535
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
3636
endif()
3737

38-
if (DEFINED ENV{QUICER_USE_OPENSSL3})
39-
message(STATUS "Use openssl3")
40-
set(QUIC_TLS "openssl3")
41-
endif()
38+
if (DEFINED ENV{QUICER_TLS_VER})
39+
if ($ENV{QUICER_TLS_VER} STREQUAL "sys")
40+
## Link to sys libcrypto, auto openssl vsn
41+
find_package(OpenSSL REQUIRED)
42+
if ("${OPENSSL_VERSION}" MATCHES "3.*")
43+
set(QUIC_TLS "openssl3" CACHE STRING "QUIC_TLS")
44+
else()
45+
set(QUIC_TLS "openssl" CACHE STRING "QUIC_TLS")
46+
endif()
47+
set(QUIC_USE_SYSTEM_LIBCRYPTO "ON")
48+
else()
49+
set(QUIC_TLS $ENV{QUICER_TLS_VER})
50+
endif()
4251

43-
if (DEFINED ENV{QUIC_USE_SYSTEM_LIBCRYPTO})
44-
message(STATUS "Link to system libcrypto")
45-
set(QUIC_USE_SYSTEM_LIBCRYPTO "ON")
4652
endif()
4753

4854
if (DEFINED ENV{QUIC_ENABLE_LOGGING})

c_src/quicer_eterms.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ extern ERL_NIF_TERM ATOM_QUIC_STATUS_UNSUPPORTED_CERTIFICATE;
104104
extern ERL_NIF_TERM ATOM_QUIC_STATUS_REVOKED_CERTIFICATE;
105105
extern ERL_NIF_TERM ATOM_QUIC_STATUS_EXPIRED_CERTIFICATE;
106106
extern ERL_NIF_TERM ATOM_QUIC_STATUS_UNKNOWN_CERTIFICATE;
107+
extern ERL_NIF_TERM ATOM_QUIC_STATUS_REQUIRED_CERTIFICATE;
107108
extern ERL_NIF_TERM ATOM_QUIC_STATUS_CERT_EXPIRED;
108109
extern ERL_NIF_TERM ATOM_QUIC_STATUS_CERT_UNTRUSTED_ROOT;
109110
extern ERL_NIF_TERM ATOM_QUIC_STATUS_CERT_NO_CERT;

c_src/quicer_nif.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ ERL_NIF_TERM ATOM_QUIC_STATUS_UNSUPPORTED_CERTIFICATE;
127127
ERL_NIF_TERM ATOM_QUIC_STATUS_REVOKED_CERTIFICATE;
128128
ERL_NIF_TERM ATOM_QUIC_STATUS_EXPIRED_CERTIFICATE;
129129
ERL_NIF_TERM ATOM_QUIC_STATUS_UNKNOWN_CERTIFICATE;
130+
ERL_NIF_TERM ATOM_QUIC_STATUS_REQUIRED_CERTIFICATE;
130131
ERL_NIF_TERM ATOM_QUIC_STATUS_CERT_EXPIRED;
131132
ERL_NIF_TERM ATOM_QUIC_STATUS_CERT_UNTRUSTED_ROOT;
132133
ERL_NIF_TERM ATOM_QUIC_STATUS_CERT_NO_CERT;
@@ -502,6 +503,7 @@ ERL_NIF_TERM ATOM_QUIC_DATAGRAM_SEND_CANCELED;
502503
ATOM(ATOM_QUIC_STATUS_REVOKED_CERTIFICATE, revoked_certificate); \
503504
ATOM(ATOM_QUIC_STATUS_EXPIRED_CERTIFICATE, expired_certificate); \
504505
ATOM(ATOM_QUIC_STATUS_UNKNOWN_CERTIFICATE, unknown_certificate); \
506+
ATOM(ATOM_QUIC_STATUS_REQUIRED_CERTIFICATE, required_certificate); \
505507
ATOM(ATOM_QUIC_STATUS_CERT_EXPIRED, cert_expired); \
506508
ATOM(ATOM_QUIC_STATUS_CERT_UNTRUSTED_ROOT, cert_untrusted_root); \
507509
ATOM(ATOM_QUIC_STATUS_CERT_NO_CERT, cert_no_cert); \
@@ -1337,6 +1339,21 @@ atom_status(ErlNifEnv *env, QUIC_STATUS status)
13371339
case QUIC_STATUS_STREAM_LIMIT_REACHED:
13381340
eterm = ATOM_QUIC_STATUS_STREAM_LIMIT_REACHED;
13391341
break;
1342+
case QUIC_STATUS_UNSUPPORTED_CERTIFICATE:
1343+
eterm = ATOM_QUIC_STATUS_UNSUPPORTED_CERTIFICATE;
1344+
break;
1345+
case QUIC_STATUS_REVOKED_CERTIFICATE:
1346+
eterm = ATOM_QUIC_STATUS_REVOKED_CERTIFICATE;
1347+
break;
1348+
case QUIC_STATUS_EXPIRED_CERTIFICATE:
1349+
eterm = ATOM_QUIC_STATUS_EXPIRED_CERTIFICATE;
1350+
break;
1351+
case QUIC_STATUS_UNKNOWN_CERTIFICATE:
1352+
eterm = ATOM_QUIC_STATUS_UNKNOWN_CERTIFICATE;
1353+
break;
1354+
case QUIC_STATUS_REQUIRED_CERTIFICATE:
1355+
eterm = ATOM_QUIC_STATUS_REQUIRED_CERTIFICATE;
1356+
break;
13401357
case QUIC_STATUS_CERT_EXPIRED:
13411358
eterm = ATOM_QUIC_STATUS_CERT_EXPIRED;
13421359
break;

pkgname.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ esac
2929
ARCH="$(uname -m)"
3030
VSN="$(git describe --tags --exact-match | head -1)"
3131

32-
OPENSSL=${QUIC_TLS:-openssl}
32+
OPENSSL=${QUICER_TLS_VER:-openssl}
3333

3434
if [ -z "$VSN" ]; then
3535
exit 0

test/prop_stateful_client_conn.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ default_listen_opts() ->
271271
default_conn_opts() ->
272272
[
273273
{alpn, ["prop"]},
274-
%% , {sslkeylogfile, "/tmp/SSLKEYLOGFILE"}
274+
%%{sslkeylogfile, "/tmp/SSLKEYLOGFILE"},
275275
{verify, none},
276276
{idle_timeout_ms, 0},
277277
{cacertfile, "./msquic/submodules/openssl/test/certs/rootCA.pem"},

test/prop_stateful_server_conn.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ default_listen_opts() ->
353353
default_conn_opts() ->
354354
[
355355
{alpn, ["prop"]},
356-
%% , {sslkeylogfile, "/tmp/SSLKEYLOGFILE"}
356+
%% {sslkeylogfile, "/tmp/SSLKEYLOGFILE"},
357357
{verify, none},
358358
{idle_timeout_ms, 5000},
359359
{cacertfile, "./msquic/submodules/openssl/test/certs/rootCA.pem"},

test/prop_stateful_stream.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ default_listen_opts() ->
323323
default_conn_opts() ->
324324
[
325325
{alpn, ["prop"]},
326-
%% , {sslkeylogfile, "/tmp/SSLKEYLOGFILE"}
326+
%% {sslkeylogfile, "/tmp/SSLKEYLOGFILE"},
327327
{verify, none},
328328
{idle_timeout_ms, 0},
329329
{handshake_idle_timeout_ms, 10000},

test/quicer_SUITE.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2424,7 +2424,7 @@ tc_conn_opt_sslkeylogfile(Config) ->
24242424
),
24252425
quicer:close_connection(Conn),
24262426
timer:sleep(100),
2427-
{ok, #file_info{type = regular}} = file:read_file_info("SSLKEYLOGFILE").
2427+
{ok, #file_info{type = regular}} = file:read_file_info(TargetFName).
24282428

24292429
tc_insecure_traffic(Config) ->
24302430
Port = select_port(),

0 commit comments

Comments
 (0)