mirror of
https://github.com/curl/curl.git
synced 2026-08-24 19:03:40 +03:00
vtls: add options to specify range of enabled TLS versions
This commit introduces the CURL_SSLVERSION_MAX_* constants as well as the --tls-max option of the curl tool. Closes https://github.com/curl/curl/pull/1166
This commit is contained in:
parent
b666907336
commit
6448f98c18
25 changed files with 781 additions and 227 deletions
|
|
@ -156,6 +156,7 @@ struct OperationConfig {
|
|||
struct curl_slist *postquote;
|
||||
struct curl_slist *prequote;
|
||||
long ssl_version;
|
||||
long ssl_version_max;
|
||||
long proxy_ssl_version;
|
||||
long ip_version;
|
||||
curl_TimeCond timecond;
|
||||
|
|
|
|||
|
|
@ -184,6 +184,7 @@ static const struct LongShort aliases[]= {
|
|||
{"$S", "tftp-no-options", FALSE},
|
||||
{"$U", "connect-to", TRUE},
|
||||
{"$W", "abstract-unix-socket", TRUE},
|
||||
{"$X", "tls-max", TRUE},
|
||||
{"0", "http1.0", FALSE},
|
||||
{"01", "http1.1", FALSE},
|
||||
{"02", "http2", FALSE},
|
||||
|
|
@ -1060,6 +1061,11 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||
config->abstract_unix_socket = TRUE;
|
||||
GetStr(&config->unix_socket_path, nextarg);
|
||||
break;
|
||||
case 'X': /* --tls-max */
|
||||
err = str2tls_max(&config->ssl_version_max, nextarg);
|
||||
if(err)
|
||||
return err;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case '#': /* --progress-bar */
|
||||
|
|
|
|||
|
|
@ -260,6 +260,7 @@ static const char *const helptext[] = {
|
|||
" --tlsv1.1 Use TLSv1.1 (SSL)",
|
||||
" --tlsv1.2 Use TLSv1.2 (SSL)",
|
||||
" --tlsv1.3 Use TLSv1.3 (SSL)",
|
||||
" --tls-max VERSION Use TLS up to VERSION (SSL)",
|
||||
" --trace FILE Write a debug trace to FILE",
|
||||
" --trace-ascii FILE Like --trace, but without hex output",
|
||||
" --trace-time Add time stamps to trace/verbose output",
|
||||
|
|
|
|||
|
|
@ -1087,7 +1087,8 @@ static CURLcode operate_do(struct GlobalConfig *global,
|
|||
if(config->falsestart)
|
||||
my_setopt(curl, CURLOPT_SSL_FALSESTART, 1L);
|
||||
|
||||
my_setopt_enum(curl, CURLOPT_SSLVERSION, config->ssl_version);
|
||||
my_setopt_enum(curl, CURLOPT_SSLVERSION,
|
||||
config->ssl_version | config->ssl_version_max);
|
||||
my_setopt_enum(curl, CURLOPT_PROXY_SSLVERSION,
|
||||
config->proxy_ssl_version);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -550,3 +550,36 @@ CURLcode get_args(struct OperationConfig *config, const size_t i)
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse the string and modify ssl_version in the val argument. Return PARAM_OK
|
||||
* on success, otherwise a parameter error enum. ONLY ACCEPTS POSITIVE NUMBERS!
|
||||
*
|
||||
* Since this function gets called with the 'nextarg' pointer from within the
|
||||
* getparameter a lot, we must check it for NULL before accessing the str
|
||||
* data.
|
||||
*/
|
||||
|
||||
ParameterError str2tls_max(long *val, const char *str)
|
||||
{
|
||||
static struct s_tls_max {
|
||||
const char *tls_max_str;
|
||||
long tls_max;
|
||||
} const tls_max_array[] = {
|
||||
{ "default", CURL_SSLVERSION_MAX_DEFAULT },
|
||||
{ "1.0", CURL_SSLVERSION_MAX_TLSv1_0 },
|
||||
{ "1.1", CURL_SSLVERSION_MAX_TLSv1_1 },
|
||||
{ "1.2", CURL_SSLVERSION_MAX_TLSv1_2 },
|
||||
{ "1.3", CURL_SSLVERSION_MAX_TLSv1_3 }
|
||||
};
|
||||
size_t i = 0;
|
||||
if(!str)
|
||||
return PARAM_REQUIRES_PARAMETER;
|
||||
for(i = 0; i < sizeof(tls_max_array)/sizeof(tls_max_array[0]); i++) {
|
||||
if(!strcmp(str, tls_max_array[i].tls_max_str)) {
|
||||
*val = tls_max_array[i].tls_max;
|
||||
return PARAM_OK;
|
||||
}
|
||||
}
|
||||
return PARAM_BAD_USE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,4 +52,6 @@ int ftpcccmethod(struct OperationConfig *config, const char *str);
|
|||
|
||||
long delegation(struct OperationConfig *config, char *str);
|
||||
|
||||
ParameterError str2tls_max(long *val, const char *str);
|
||||
|
||||
#endif /* HEADER_CURL_TOOL_PARAMHLP_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue