Skip to content

Commit 9a44dee

Browse files
vszakatspps83
authored andcommitted
sectransp: add support for HTTP/2 in gcc builds
Before this patch `--http2` did not work in gcc builds with Secure Transport, because ALPN relied on a compiler supporting the `HAVE_BUILTIN_AVAILABLE` aka `__builtin_available()` feature. This is clang-specific and missing from gcc (as of gcc v14). Add support for ALPN and HTTP/2 when this compiler feature is missing. Also drop test exceptions from GHA/macos in CI. Follow-up to 092f681 Ref: c349bd6 curl#14097 (issue 15.) Ref: curl#4314 Closes curl#16581
1 parent a1e594a commit 9a44dee

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

.github/workflows/macos.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,6 @@ jobs:
314314
export TFLAGS='-j20 ${{ matrix.build.tflags }}'
315315
if [ -z '${{ matrix.build.torture }}' ]; then
316316
TFLAGS+=' ~2037 ~2041' # flaky
317-
if [[ '${{ matrix.compiler }}' = 'gcc'* ]]; then
318-
if [[ '${{ matrix.build.configure }}' = *'--with-secure-transport'* || \
319-
'${{ matrix.build.generate }}' = *'-DCURL_USE_SECTRANSP=ON'* ]]; then
320-
TFLAGS+=' ~HTTP/2' # 2400 2401 2402 2403 2404 2406, Secure Transport + nghttp2
321-
fi
322-
fi
323317
if [[ '${{ matrix.build.configure }}' = *'--with-secure-transport'* || \
324318
'${{ matrix.build.generate }}' = *'-DCURL_USE_SECTRANSP=ON'* ]]; then
325319
TFLAGS+=' ~313' # Secure Transport does not support crl file

lib/vtls/sectransp.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,10 +1091,13 @@ static CURLcode sectransp_connect_step1(struct Curl_cfilter *cf,
10911091
if(result != CURLE_OK)
10921092
return result;
10931093

1094+
if(connssl->alpn) {
10941095
#if (CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) && \
10951096
defined(HAVE_BUILTIN_AVAILABLE)
1096-
if(connssl->alpn) {
10971097
if(__builtin_available(macOS 10.13.4, iOS 11, tvOS 11, *)) {
1098+
#else
1099+
if(&SSLSetALPNProtocols && &SSLCopyALPNProtocols) {
1100+
#endif
10981101
struct alpn_proto_buf proto;
10991102
size_t i;
11001103
CFStringRef cstr;
@@ -1117,7 +1120,6 @@ static CURLcode sectransp_connect_step1(struct Curl_cfilter *cf,
11171120
infof(data, VTLS_INFOF_ALPN_OFFER_1STR, proto.data);
11181121
}
11191122
}
1120-
#endif
11211123

11221124
if(ssl_config->key) {
11231125
infof(data, "WARNING: SSL: CURLOPT_SSLKEY is ignored by Secure "
@@ -2088,10 +2090,13 @@ static CURLcode sectransp_connect_step2(struct Curl_cfilter *cf,
20882090
break;
20892091
}
20902092

2093+
if(connssl->alpn) {
20912094
#if (CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) && \
20922095
defined(HAVE_BUILTIN_AVAILABLE)
2093-
if(connssl->alpn) {
20942096
if(__builtin_available(macOS 10.13.4, iOS 11, tvOS 11, *)) {
2097+
#else
2098+
if(&SSLSetALPNProtocols && &SSLCopyALPNProtocols) {
2099+
#endif
20952100
CFArrayRef alpnArr = NULL;
20962101
CFStringRef chosenProtocol = NULL;
20972102
err = SSLCopyALPNProtocols(backend->ssl_ctx, &alpnArr);
@@ -2119,7 +2124,6 @@ static CURLcode sectransp_connect_step2(struct Curl_cfilter *cf,
21192124
CFRelease(alpnArr);
21202125
}
21212126
}
2122-
#endif
21232127

21242128
return CURLE_OK;
21252129
}

0 commit comments

Comments
 (0)