Skip to content

Commit fab3cdb

Browse files
Merge branch 'master' into fix-macos-build-warnings
2 parents d6b7ada + 91ca3e8 commit fab3cdb

23 files changed

Lines changed: 248 additions & 27 deletions

.github/workflows/unittest_linux.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ on:
33
push:
44
paths-ignore:
55
- 'docs/**'
6+
branches: [ master ] # CI on PRs targeting master
67
pull_request:
8+
branches: [ master ] # CI on PRs targeting master
79

810
jobs:
911
linux:

.github/workflows/unittest_linux_asan.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ on:
33
push:
44
paths-ignore:
55
- 'docs/**'
6+
branches: [ master ] # CI on PRs targeting master
67
pull_request:
8+
branches: [ master ] # CI on PRs targeting master
79

810
jobs:
911
linux:

.github/workflows/unittest_mac_tsan_mbedtls.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ on:
33
push:
44
paths-ignore:
55
- 'docs/**'
6+
branches: [ master ] # CI on PRs targeting master
67
pull_request:
8+
branches: [ master ] # CI on PRs targeting master
79

810
jobs:
911
mac_tsan_mbedtls:

.github/workflows/unittest_mac_tsan_openssl.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ on:
33
push:
44
paths-ignore:
55
- 'docs/**'
6+
branches: [ master ] # CI on PRs targeting master
67
pull_request:
8+
branches: [ master ] # CI on PRs targeting master
79

810
jobs:
911
mac_tsan_openssl:

.github/workflows/unittest_mac_tsan_sectransport.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ on:
33
push:
44
paths-ignore:
55
- 'docs/**'
6+
branches: [ master ] # CI on PRs targeting master
67
pull_request:
8+
branches: [ master ] # CI on PRs targeting master
79

810
jobs:
911
mac_tsan_sectransport:

.github/workflows/unittest_uwp.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ on:
33
push:
44
paths-ignore:
55
- 'docs/**'
6+
branches: [ master ] # CI on PRs targeting master
67
pull_request:
8+
branches: [ master ] # CI on PRs targeting master
79

810
jobs:
911
uwp:

.github/workflows/unittest_windows_gcc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ on:
33
push:
44
paths-ignore:
55
- 'docs/**'
6+
branches: [ master ] # CI on PRs targeting master
67
pull_request:
8+
branches: [ master ] # CI on PRs targeting master
79

810
jobs:
911
windows:

ixwebsocket/IXHttpServer.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "IXGzipCodec.h"
1010
#include "IXNetSystem.h"
1111
#include "IXSocketConnect.h"
12+
#include "IXStrCaseCompare.h"
1213
#include "IXUserAgent.h"
1314
#include <cstdint>
1415
#include <cstring>
@@ -98,7 +99,11 @@ namespace ix
9899
{
99100
auto request = std::get<2>(ret);
100101
std::shared_ptr<ix::HttpResponse> response;
101-
if (request->headers["Upgrade"] == "websocket")
102+
// The Upgrade header value is case-insensitive (RFC 6455 4.2.1);
103+
// e.g. Chrome's remote-debugging proxy sends "Upgrade: WebSocket".
104+
const std::string& upgradeHeader = request->headers["Upgrade"];
105+
if (!CaseInsensitiveLess::cmp(upgradeHeader, "websocket") &&
106+
!CaseInsensitiveLess::cmp("websocket", upgradeHeader))
102107
{
103108
WebSocketServer::handleUpgrade(std::move(socket), connectionState, request);
104109
}

ixwebsocket/IXSocketMbedTLS.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,18 @@ namespace ix
4242

4343
mbedtls_ssl_init(&_ssl);
4444
mbedtls_ssl_config_init(&_conf);
45+
#if MBEDTLS_VERSION_MAJOR < 4
4546
mbedtls_ctr_drbg_init(&_ctr_drbg);
4647
mbedtls_entropy_init(&_entropy);
48+
#endif
4749
mbedtls_x509_crt_init(&_cacert);
4850
mbedtls_x509_crt_init(&_cert);
4951
mbedtls_pk_init(&_pkey);
50-
// Initialize the PSA Crypto API if required by the version of Mbed TLS (3.6.0).
51-
// This allows the X.509/TLS libraries to use PSA for crypto operations.
52+
// Initialize the PSA Crypto API for mbedTLS 3.6+ and all 4.x releases.
5253
// See: https://github.com/Mbed-TLS/mbedtls/blob/development/docs/use-psa-crypto.md
53-
if (MBEDTLS_VERSION_MAJOR >= 3 && MBEDTLS_VERSION_MINOR >= 6 && MBEDTLS_VERSION_PATCH >= 0)
54-
{
55-
psa_crypto_init();
56-
}
54+
#if MBEDTLS_VERSION_MAJOR >= 4 || (MBEDTLS_VERSION_MAJOR == 3 && MBEDTLS_VERSION_MINOR >= 6)
55+
psa_crypto_init();
56+
#endif
5757
}
5858

5959
bool SocketMbedTLS::loadSystemCertificates(std::string& errorMsg)
@@ -112,6 +112,7 @@ namespace ix
112112

113113
const char* pers = "IXSocketMbedTLS";
114114

115+
#if MBEDTLS_VERSION_MAJOR < 4
115116
if (mbedtls_ctr_drbg_seed(&_ctr_drbg,
116117
mbedtls_entropy_func,
117118
&_entropy,
@@ -121,6 +122,7 @@ namespace ix
121122
errMsg = "Setting entropy seed failed";
122123
return false;
123124
}
125+
#endif
124126

125127
if (mbedtls_ssl_config_defaults(&_conf,
126128
(isClient) ? MBEDTLS_SSL_IS_CLIENT : MBEDTLS_SSL_IS_SERVER,
@@ -131,7 +133,9 @@ namespace ix
131133
return false;
132134
}
133135

136+
#if MBEDTLS_VERSION_MAJOR < 4
134137
mbedtls_ssl_conf_rng(&_conf, mbedtls_ctr_drbg_random, &_ctr_drbg);
138+
#endif
135139

136140
if (_tlsOptions.hasCertAndKey())
137141
{
@@ -140,7 +144,7 @@ namespace ix
140144
errMsg = "Cannot parse cert file '" + _tlsOptions.certFile + "'";
141145
return false;
142146
}
143-
#ifdef IXWEBSOCKET_USE_MBED_TLS_MIN_VERSION_3
147+
#if MBEDTLS_VERSION_MAJOR == 3
144148
if (mbedtls_pk_parse_keyfile(&_pkey, _tlsOptions.keyFile.c_str(), "", mbedtls_ctr_drbg_random, &_ctr_drbg) < 0)
145149
#else
146150
if (mbedtls_pk_parse_keyfile(&_pkey, _tlsOptions.keyFile.c_str(), "") < 0)
@@ -317,15 +321,16 @@ namespace ix
317321

318322
mbedtls_ssl_free(&_ssl);
319323
mbedtls_ssl_config_free(&_conf);
324+
#if MBEDTLS_VERSION_MAJOR < 4
320325
mbedtls_ctr_drbg_free(&_ctr_drbg);
321326
mbedtls_entropy_free(&_entropy);
327+
#endif
322328
mbedtls_x509_crt_free(&_cacert);
323329
mbedtls_x509_crt_free(&_cert);
324330
mbedtls_pk_free(&_pkey);
325-
if (MBEDTLS_VERSION_MAJOR >= 3 && MBEDTLS_VERSION_MINOR >= 6 && MBEDTLS_VERSION_PATCH >= 0)
326-
{
327-
mbedtls_psa_crypto_free();
328-
}
331+
#if MBEDTLS_VERSION_MAJOR >= 4 || (MBEDTLS_VERSION_MAJOR == 3 && MBEDTLS_VERSION_MINOR >= 6)
332+
mbedtls_psa_crypto_free();
333+
#endif
329334

330335
Socket::close();
331336
}

ixwebsocket/IXSocketMbedTLS.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99

1010
#include "IXSocket.h"
1111
#include "IXSocketTLSOptions.h"
12+
#include <mbedtls/version.h>
13+
#if MBEDTLS_VERSION_MAJOR < 4
1214
#include <mbedtls/ctr_drbg.h>
13-
#include <mbedtls/debug.h>
1415
#include <mbedtls/entropy.h>
16+
#endif
17+
#include <mbedtls/debug.h>
1518
#include <mbedtls/error.h>
1619
#include <mbedtls/net_sockets.h>
1720
#include <mbedtls/platform.h>
@@ -41,8 +44,10 @@ namespace ix
4144
private:
4245
mbedtls_ssl_context _ssl;
4346
mbedtls_ssl_config _conf;
47+
#if MBEDTLS_VERSION_MAJOR < 4
4448
mbedtls_entropy_context _entropy;
4549
mbedtls_ctr_drbg_context _ctr_drbg;
50+
#endif
4651
mbedtls_x509_crt _cacert;
4752
mbedtls_x509_crt _cert;
4853
mbedtls_pk_context _pkey;

0 commit comments

Comments
 (0)