@@ -146,6 +146,67 @@ def HasCurlOption(self, option):
146146 return self.CheckOutput(['curl', '--help', 'all'], default, "Curl needs to support option: {option}".format(option=option))
147147
148148
149+ def HasCurlTLSVersionSupport(self, tls_version):
150+ """Check whether curl can attempt a given TLS version.
151+
152+ This probes curl directly because OpenSSL capability checks do not always
153+ reflect curl runtime policy behavior on hardened systems.
154+ """
155+
156+ def check_curl_tls_support():
157+ # Map semantic versions used by tests to curl flags.
158+ version_map = {
159+ "1.0": ("--tlsv1", "1.0"),
160+ "1.1": ("--tlsv1.1", "1.1"),
161+ "1.2": ("--tlsv1.2", "1.2"),
162+ "1.3": ("--tlsv1.3", "1.3"),
163+ }
164+ if tls_version not in version_map:
165+ return False
166+
167+ tls_flag, tls_max = version_map[tls_version]
168+ try:
169+ # Connect to localhost closed port to avoid network dependencies.
170+ # "connection refused" means curl accepted the TLS flags and tried.
171+ result = subprocess.run(
172+ [
173+ "curl",
174+ "-svk",
175+ "--connect-timeout",
176+ "2",
177+ "--max-time",
178+ "3",
179+ tls_flag,
180+ "--tls-max",
181+ tls_max,
182+ "https://127.0.0.1:1",
183+ ],
184+ capture_output=True,
185+ text=True,
186+ timeout=5,
187+ )
188+ output = (result.stdout + result.stderr).lower()
189+ unsupported_markers = [
190+ "unsupported protocol",
191+ "no protocols available",
192+ "option --tlsv",
193+ "unknown option",
194+ "is unknown",
195+ ]
196+ if any(marker in output for marker in unsupported_markers):
197+ return False
198+
199+ # Any attempt to connect implies curl accepted the TLS setting.
200+ return True
201+ except subprocess.TimeoutExpired:
202+ return False
203+ except Exception:
204+ return False
205+
206+ return self.Condition(
207+ check_curl_tls_support, "Curl does not support TLSv{version} in this environment".format(version=tls_version))
208+
209+
149210def HasATSFeature(self, feature):
150211
151212 val = self.Variables.get(feature, None)
@@ -175,5 +236,6 @@ ExtendCondition(HasATSFeature)
175236ExtendCondition(HasCurlVersion)
176237ExtendCondition(HasCurlFeature)
177238ExtendCondition(HasCurlOption)
239+ ExtendCondition(HasCurlTLSVersionSupport)
178240ExtendCondition(PluginExists)
179241ExtendCondition(CurlUsingUnixDomainSocket)
0 commit comments