Skip to content

Commit a9486df

Browse files
committed
patch curl for awc-lc ech suppport PR15499, enable
1 parent abcf53f commit a9486df

File tree

2 files changed

+171
-1
lines changed

2 files changed

+171
-1
lines changed

curl.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,11 @@ _VER="$1"
198198
if [ "${_OPENSSL}" = 'boringssl' ] || [ "${_OPENSSL}" = 'awslc' ]; then
199199
if [ "${_OPENSSL}" = 'boringssl' ]; then
200200
CPPFLAGS+=" -DCURL_BORINGSSL_VERSION=\\\"${BORINGSSL_VER_}\\\""
201-
options+=' -DUSE_HTTPSRR=ON -DUSE_ECH=ON'
202201
options+=' -DHAVE_BORINGSSL=1 -DHAVE_AWSLC=0' # fast-track configuration
203202
else
204203
options+=' -DHAVE_BORINGSSL=0 -DHAVE_AWSLC=1' # fast-track configuration
205204
fi
205+
options+=' -DUSE_HTTPSRR=ON -DUSE_ECH=ON'
206206
LIBS+=' -lpthread'
207207
h3=1
208208
else

curl.test.patch

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,173 @@ index d854d364f..49daeaa4e 100644
103103
}
104104
else
105105
/* junk input => zero length output */
106+
diff --git a/CMakeLists.txt b/CMakeLists.txt
107+
index c4ba74d9fb5a05..aebbc719517713 100644
108+
--- a/CMakeLists.txt
109+
+++ b/CMakeLists.txt
110+
@@ -851,7 +851,7 @@ if(USE_ECH)
111+
if(USE_OPENSSL OR USE_WOLFSSL)
112+
# Be sure that the TLS library actually supports ECH.
113+
if(NOT DEFINED HAVE_ECH)
114+
- if(USE_OPENSSL AND HAVE_BORINGSSL)
115+
+ if(USE_OPENSSL AND (HAVE_BORINGSSL OR HAVE_AWSLC))
116+
openssl_check_symbol_exists("SSL_set1_ech_config_list" "openssl/ssl.h" HAVE_ECH "")
117+
elseif(USE_OPENSSL)
118+
openssl_check_symbol_exists("SSL_ech_set1_echconfig" "openssl/ech.h" HAVE_ECH "")
119+
@@ -860,12 +860,12 @@ if(USE_ECH)
120+
endif()
121+
endif()
122+
if(NOT HAVE_ECH)
123+
- message(FATAL_ERROR "ECH support missing in OpenSSL/BoringSSL/wolfSSL")
124+
+ message(FATAL_ERROR "ECH support missing in OpenSSL/BoringSSL/AWS-LC/wolfSSL")
125+
else()
126+
message(STATUS "ECH enabled.")
127+
endif()
128+
else()
129+
- message(FATAL_ERROR "ECH requires ECH-enablded OpenSSL, BoringSSL or wolfSSL")
130+
+ message(FATAL_ERROR "ECH requires ECH-enablded OpenSSL, BoringSSL, AWS-LC or wolfSSL")
131+
endif()
132+
endif()
133+
134+
diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
135+
index e8be5d0ccd9104..804cdebc648032 100644
136+
--- a/lib/vtls/openssl.c
137+
+++ b/lib/vtls/openssl.c
138+
@@ -83,7 +83,7 @@
139+
#include <openssl/evp.h>
140+
141+
#ifdef USE_ECH
142+
-# ifndef OPENSSL_IS_BORINGSSL
143+
+# if !defined(OPENSSL_IS_BORINGSSL) && !defined(OPENSSL_IS_AWSLC)
144+
# include <openssl/ech.h>
145+
# endif
146+
# include "curl_base64.h"
147+
@@ -3849,15 +3849,15 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx,
148+
149+
if(data->set.tls_ech & CURLECH_GREASE) {
150+
infof(data, "ECH: will GREASE ClientHello");
151+
-# ifdef OPENSSL_IS_BORINGSSL
152+
+# if defined(OPENSSL_IS_BORINGSSL) || defined(OPENSSL_IS_AWSLC)
153+
SSL_set_enable_ech_grease(octx->ssl, 1);
154+
# else
155+
SSL_set_options(octx->ssl, SSL_OP_ECH_GREASE);
156+
# endif
157+
}
158+
else if(data->set.tls_ech & CURLECH_CLA_CFG) {
159+
-# ifdef OPENSSL_IS_BORINGSSL
160+
- /* have to do base64 decode here for boring */
161+
+# if defined(OPENSSL_IS_BORINGSSL) || defined(OPENSSL_IS_AWSLC)
162+
+ /* have to do base64 decode here for BoringSSL */
163+
const char *b64 = data->set.str[STRING_ECH_CONFIG];
164+
165+
if(!b64) {
166+
@@ -3917,7 +3917,7 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx,
167+
size_t elen = rinfo->echconfiglist_len;
168+
169+
infof(data, "ECH: ECHConfig from DoH HTTPS RR");
170+
-# ifndef OPENSSL_IS_BORINGSSL
171+
+# if !defined(OPENSSL_IS_BORINGSSL) && !defined(OPENSSL_IS_AWSLC)
172+
if(SSL_ech_set1_echconfig(octx->ssl, ecl, elen) != 1) {
173+
infof(data, "ECH: SSL_ECH_set1_echconfig failed");
174+
if(data->set.tls_ech & CURLECH_HARD)
175+
@@ -3925,7 +3925,7 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx,
176+
}
177+
# else
178+
if(SSL_set1_ech_config_list(octx->ssl, ecl, elen) != 1) {
179+
- infof(data, "ECH: SSL_set1_ech_config_list failed (boring)");
180+
+ infof(data, "ECH: SSL_set1_ech_config_list failed (BoringSSL)");
181+
if(data->set.tls_ech & CURLECH_HARD)
182+
return CURLE_SSL_CONNECT_ERROR;
183+
}
184+
@@ -3943,7 +3943,7 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx,
185+
Curl_resolv_unlink(data, &dns);
186+
}
187+
}
188+
-# ifdef OPENSSL_IS_BORINGSSL
189+
+# if defined(OPENSSL_IS_BORINGSSL) || defined(OPENSSL_IS_AWSLC)
190+
if(trying_ech_now && outername) {
191+
infof(data, "ECH: setting public_name not supported with BoringSSL");
192+
return CURLE_SSL_CONNECT_ERROR;
193+
@@ -3960,7 +3960,7 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx,
194+
return CURLE_SSL_CONNECT_ERROR;
195+
}
196+
}
197+
-# endif /* not BORING */
198+
+# endif /* OPENSSL_IS_BORINGSSL || OPENSSL_IS_AWSLC */
199+
if(trying_ech_now
200+
&& SSL_set_min_proto_version(octx->ssl, TLS1_3_VERSION) != 1) {
201+
infof(data, "ECH: cannot force TLSv1.3 [ERROR]");
202+
@@ -4071,7 +4071,7 @@ static void ossl_trace_ech_retry_configs(struct Curl_easy *data, SSL* ssl,
203+
CURLcode result = CURLE_OK;
204+
size_t rcl = 0;
205+
int rv = 1;
206+
-# ifndef OPENSSL_IS_BORINGSSL
207+
+# if !defined(OPENSSL_IS_BORINGSSL) && !defined(OPENSSL_IS_AWSLC)
208+
char *inner = NULL;
209+
unsigned char *rcs = NULL;
210+
char *outer = NULL;
211+
@@ -4086,7 +4086,7 @@ static void ossl_trace_ech_retry_configs(struct Curl_easy *data, SSL* ssl,
212+
/* nothing to trace if not doing ECH */
213+
if(!ECH_ENABLED(data))
214+
return;
215+
-# ifndef OPENSSL_IS_BORINGSSL
216+
+# if !defined(OPENSSL_IS_BORINGSSL) && !defined(OPENSSL_IS_AWSLC)
217+
rv = SSL_ech_get_retry_config(ssl, &rcs, &rcl);
218+
# else
219+
SSL_get0_ech_retry_configs(ssl, &rcs, &rcl);
220+
@@ -4103,23 +4103,23 @@ static void ossl_trace_ech_retry_configs(struct Curl_easy *data, SSL* ssl,
221+
if(!result && b64str)
222+
infof(data, "ECH: retry_configs %s", b64str);
223+
free(b64str);
224+
-# ifndef OPENSSL_IS_BORINGSSL
225+
+# if !defined(OPENSSL_IS_BORINGSSL) && !defined(OPENSSL_IS_AWSLC)
226+
rv = SSL_ech_get_status(ssl, &inner, &outer);
227+
infof(data, "ECH: retry_configs for %s from %s, %d %d",
228+
inner ? inner : "NULL", outer ? outer : "NULL", reason, rv);
229+
-#else
230+
+# else
231+
rv = SSL_ech_accepted(ssl);
232+
servername_type = SSL_get_servername_type(ssl);
233+
inner = SSL_get_servername(ssl, servername_type);
234+
SSL_get0_ech_name_override(ssl, &outer, &out_name_len);
235+
- /* TODO: get the inner from boring */
236+
+ /* TODO: get the inner from BoringSSL */
237+
infof(data, "ECH: retry_configs for %s from %s, %d %d",
238+
inner ? inner : "NULL", outer ? outer : "NULL", reason, rv);
239+
-#endif
240+
+# endif
241+
}
242+
else
243+
infof(data, "ECH: no retry_configs (rv = %d)", rv);
244+
-# ifndef OPENSSL_IS_BORINGSSL
245+
+# if !defined(OPENSSL_IS_BORINGSSL) && !defined(OPENSSL_IS_AWSLC)
246+
OPENSSL_free((void *)rcs);
247+
# endif
248+
return;
249+
@@ -4243,7 +4243,7 @@ static CURLcode ossl_connect_step2(struct Curl_cfilter *cf,
250+
#endif
251+
#ifdef USE_ECH
252+
else if((lib == ERR_LIB_SSL) &&
253+
-# ifndef OPENSSL_IS_BORINGSSL
254+
+# if !defined(OPENSSL_IS_BORINGSSL) && !defined(OPENSSL_IS_AWSLC)
255+
(reason == SSL_R_ECH_REQUIRED)) {
256+
# else
257+
(reason == SSL_R_ECH_REJECTED)) {
258+
@@ -4309,7 +4309,7 @@ static CURLcode ossl_connect_step2(struct Curl_cfilter *cf,
259+
OBJ_nid2sn(psigtype_nid));
260+
261+
#ifdef USE_ECH
262+
-# ifndef OPENSSL_IS_BORINGSSL
263+
+# if !defined(OPENSSL_IS_BORINGSSL) && !defined(OPENSSL_IS_AWSLC)
264+
if(ECH_ENABLED(data)) {
265+
char *inner = NULL, *outer = NULL;
266+
const char *status = NULL;
267+
@@ -4367,7 +4367,7 @@ static CURLcode ossl_connect_step2(struct Curl_cfilter *cf,
268+
else {
269+
infof(data, "ECH: result: status is not attempted");
270+
}
271+
-# endif /* BORING */
272+
+# endif /* !OPENSSL_IS_BORINGSSL && !OPENSSL_IS_AWSLC */
273+
#endif /* USE_ECH */
274+
275+
#ifdef HAS_ALPN

0 commit comments

Comments
 (0)