New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added flags CURL_SSLVERSION_OR_UP_TO_* to CURLOPT_SSLVERSION #1166
Closed
Closed
Changes from 4 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
21143bc
tls-max: Added flags CURL_SSLVERSION_OR_UP_TO_* to CURLOPT_SSLVERSION
03918ee
fix of SPACEBEFOREPAREN
8a5b3ab
added missing symbols in versions:
007fc8c
fix documentation and added curl.1
d90c799
fix of help: renamed up-to-tls-tlsv to up-to-tlsv
b48f5cb
refactoring tool curl: tls-max instead of up-to-tls*
c38fb2a
refactor: rename CURL_SSLVERSION_OR_UP_TO* to CURL_SSLVERSION_MAX*
dc572c9
refactoring: remove recursion from set_ssl_version_min_max
e4ae8ba
Added flags CURL_SSLVERSION_OR_UP_TO_* to CURLOPT_SSLVERSION
1521c82
Removing unnecessary sentences about minimum SSL versions
f43ce22
Renaming GET/SET_CURL_SSLVERSION to CURL_GET/SET_SSLVERSION
2526749
CURL_SSLVERSION_MAX_DEFAULT with own value.
6cd599d
Added recent documentation
352116f
Added missing symbols (symbols-in-versions)
f28e480
Fix of documentation
8d5756e
Removing docs/curl.1
f178c42
removed macro CURL_SET_SSLVERSION_MAX
a218844
CURL_GET_SSLVERSION, CURL_GET_SSLVERSION removed
fbdab0a
curl.h: assign CURL_SSLVERSION_MAX_* constants systematically
kdudka 0523638
nss: simplify the code of SSL version mapping
kdudka 0b7992f
simplify sets min, max of ssl version in ssl libraries
426d1cd
fix of shifts
9812598
fix of doc: added CURL_SSLVERSION_MAX_TLSv1_0
5a2477f
use first member to calc size of array
ff5bb77
fix of windows compilation
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Long: up-to-tls-default | ||
Tags: Versions | ||
Protocols: SSL | ||
Added: 7.53.0 | ||
Mutexed: up-to-tlsv1.1 up-to-tlsv1.2 up-to-tlsv1.3 | ||
Requires: TLS | ||
See-also: tlsv1.0 tlsv1.1 | ||
Help: Use TLSv1.0 or greater | ||
--- | ||
Use TLS up to recommended TLS version. | ||
|
||
It defines a range of supported TLS versions. The minimum must be defined by | ||
tlsv1.0 or tlsv1.1 and the maximum is defined by this argument. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Long: up-to-tlsv1.1 | ||
Tags: Versions | ||
Protocols: SSL | ||
Added: 7.53.0 | ||
Mutexed: up-to-tls-default up-to-tlsv1.2 up-to-tlsv1.3 | ||
Requires: TLS | ||
See-also: tlsv1.0 | ||
Help: Use TLSv1.0 or greater | ||
--- | ||
Use TLS up to TLSv1.1. | ||
|
||
It defines a range of supported TLS versions. The minimum must be defined by | ||
tlsv1.0 and the maximum is defined by this argument. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Long: up-to-tlsv1.2 | ||
Tags: Versions | ||
Protocols: SSL | ||
Added: 7.53.0 | ||
Mutexed: up-to-tls-default up-to-tlsv1.1 up-to-tlsv1.3 | ||
Requires: TLS | ||
See-also: tlsv1.0 tlsv1.1 | ||
Help: Use TLSv1.0 or greater | ||
--- | ||
Use TLS up to TLSv1.2. | ||
|
||
It defines a range of supported TLS versions. The minimum must be defined by | ||
tlsv1.0 or tlsv1.1 and the maximum is defined by this argument. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Long: up-to-tlsv1.3 | ||
Tags: Versions | ||
Protocols: SSL | ||
Added: 7.53.0 | ||
Mutexed: up-to-tls-default up-to-tlsv1.1 up-to-tlsv1.2 | ||
Requires: TLS | ||
See-also: tlsv1.0 tlsv1.1 tlsv1.2 | ||
Help: Use TLSv1.0 or greater | ||
--- | ||
Use TLS up to TLSv1.3. | ||
|
||
It defines a range of supported TLS versions. The minimum must be defined by | ||
tlsv1.0 or tlsv1.1 or tlsv1.2 and the maximum is defined by this | ||
argument. |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1042,6 +1042,129 @@ CF_INLINE bool is_file(const char *filename) | |
return false; | ||
} | ||
|
||
static CURLcode | ||
set_ssl_version_up_to(struct connectdata *conn, int sockindex, | ||
long ssl_version, long ssl_version_up_to) | ||
{ | ||
struct Curl_easy *data = conn->data; | ||
struct ssl_connect_data *connssl = &conn->ssl[sockindex]; | ||
|
||
switch(ssl_version_up_to) { | ||
case CURL_SSLVERSION_OR_UP_TO_NONE: | ||
switch(ssl_version) { | ||
case CURL_SSLVERSION_TLSv1_0: | ||
return set_ssl_version_up_to(conn, sockindex, ssl_version, | ||
CURL_SSLVERSION_OR_UP_TO_TLSv1_0); | ||
case CURL_SSLVERSION_TLSv1_1: | ||
return set_ssl_version_up_to(conn, sockindex, ssl_version, | ||
CURL_SSLVERSION_OR_UP_TO_TLSv1_1); | ||
case CURL_SSLVERSION_TLSv1_2: | ||
return set_ssl_version_up_to(conn, sockindex, ssl_version, | ||
CURL_SSLVERSION_OR_UP_TO_TLSv1_2); | ||
case CURL_SSLVERSION_TLSv1_3: | ||
return set_ssl_version_up_to(conn, sockindex, ssl_version, | ||
CURL_SSLVERSION_OR_UP_TO_TLSv1_3); | ||
} | ||
break; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should not we handle There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
#if CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS | ||
if(SSLSetProtocolVersionMax != NULL) { | ||
SSLProtocol min_ssl_protocol = kTLSProtocol1; | ||
SSLProtocol max_ssl_protocol = kTLSProtocol1; | ||
switch(ssl_version) { | ||
case CURL_SSLVERSION_TLSv1_0: | ||
min_ssl_protocol = kTLSProtocol1; | ||
break; | ||
case CURL_SSLVERSION_TLSv1_1: | ||
min_ssl_protocol = kTLSProtocol11; | ||
break; | ||
case CURL_SSLVERSION_TLSv1_1: | ||
min_ssl_protocol = kTLSProtocol12; | ||
break; | ||
case CURL_SSLVERSION_TLSv1_3: | ||
failf(data, "DarwinSSL: TLS 1.3 is not yet supported"); | ||
return CURLE_SSL_CONNECT_ERROR; | ||
} | ||
|
||
switch(ssl_version_up_to) { | ||
case CURL_SSLVERSION_OR_UP_TO_TLSv1_0: | ||
max_ssl_protocol = kTLSProtocol1; | ||
break; | ||
case CURL_SSLVERSION_OR_UP_TO_TLSv1_1: | ||
max_ssl_protocol = kTLSProtocol11; | ||
break; | ||
case CURL_SSLVERSION_OR_UP_TO_TLSv1_2: | ||
case CURL_SSLVERSION_OR_UP_TO_TLSv1_3: | ||
max_ssl_protocol = kTLSProtocol12; | ||
break; | ||
} | ||
|
||
(void)SSLSetProtocolVersionMin(connssl->ssl_ctx, min_ssl_protocol); | ||
(void)SSLSetProtocolVersionMax(connssl->ssl_ctx, max_ssl_protocol); | ||
} | ||
else { | ||
#if CURL_SUPPORT_MAC_10_8 | ||
(void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx, | ||
kSSLProtocolAll, | ||
false); | ||
switch(conn->ssl_config.version) { | ||
case CURL_SSLVERSION_DEFAULT: | ||
case CURL_SSLVERSION_TLSv1: | ||
(void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx, | ||
kTLSProtocol1, | ||
true); | ||
(void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx, | ||
kTLSProtocol11, | ||
true); | ||
(void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx, | ||
kTLSProtocol12, | ||
true); | ||
break; | ||
case CURL_SSLVERSION_TLSv1_0: | ||
(void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx, | ||
kTLSProtocol1, | ||
true); | ||
switch(conn->ssl_config.version_up_to) { | ||
case CURL_SSLVERSION_OR_UP_TO_TLSv1_3: | ||
case CURL_SSLVERSION_OR_UP_TO_TLSv1_2: | ||
(void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx, | ||
kTLSProtocol12, | ||
true); | ||
case CURL_SSLVERSION_OR_UP_TO_TLSv1_1: | ||
(void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx, | ||
kTLSProtocol11, | ||
true); | ||
} | ||
break; | ||
case CURL_SSLVERSION_TLSv1_1: | ||
(void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx, | ||
kTLSProtocol11, | ||
true); | ||
switch(conn->ssl_config.version_up_to) { | ||
case CURL_SSLVERSION_OR_UP_TO_TLSv1_3: | ||
case CURL_SSLVERSION_OR_UP_TO_TLSv1_2: | ||
(void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx, | ||
kTLSProtocol12, | ||
true); | ||
} | ||
break; | ||
case CURL_SSLVERSION_TLSv1_2: | ||
(void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx, | ||
kTLSProtocol12, | ||
true); | ||
break; | ||
case CURL_SSLVERSION_TLSv1_3: | ||
failf(data, "DarwinSSL: TLS 1.3 is not yet supported"); | ||
return CURLE_SSL_CONNECT_ERROR; | ||
} | ||
} | ||
#endif /* CURL_SUPPORT_MAC_10_8 */ | ||
#endif /* CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS */ | ||
return CURLE_OK; | ||
} | ||
|
||
|
||
static CURLcode darwinssl_connect_step1(struct connectdata *conn, | ||
int sockindex) | ||
{ | ||
|
@@ -1111,20 +1234,16 @@ static CURLcode darwinssl_connect_step1(struct connectdata *conn, | |
(void)SSLSetProtocolVersionMax(connssl->ssl_ctx, kTLSProtocol12); | ||
break; | ||
case CURL_SSLVERSION_TLSv1_0: | ||
(void)SSLSetProtocolVersionMin(connssl->ssl_ctx, kTLSProtocol1); | ||
(void)SSLSetProtocolVersionMax(connssl->ssl_ctx, kTLSProtocol1); | ||
break; | ||
case CURL_SSLVERSION_TLSv1_1: | ||
(void)SSLSetProtocolVersionMin(connssl->ssl_ctx, kTLSProtocol11); | ||
(void)SSLSetProtocolVersionMax(connssl->ssl_ctx, kTLSProtocol11); | ||
break; | ||
case CURL_SSLVERSION_TLSv1_2: | ||
(void)SSLSetProtocolVersionMin(connssl->ssl_ctx, kTLSProtocol12); | ||
(void)SSLSetProtocolVersionMax(connssl->ssl_ctx, kTLSProtocol12); | ||
break; | ||
case CURL_SSLVERSION_TLSv1_3: | ||
failf(data, "DarwinSSL: TLS 1.3 is not yet supported"); | ||
return CURLE_SSL_CONNECT_ERROR; | ||
{ | ||
CURLcode result = set_ssl_version_up_to(conn, sockindex, | ||
conn->ssl_config.version, | ||
conn->ssl_config.version_up_to); | ||
if(result != CURLE_OK) | ||
return result; | ||
} break; | ||
case CURL_SSLVERSION_SSLv3: | ||
err = SSLSetProtocolVersionMin(connssl->ssl_ctx, kSSLProtocol3); | ||
if(err != noErr) { | ||
|
@@ -1165,23 +1284,16 @@ static CURLcode darwinssl_connect_step1(struct connectdata *conn, | |
true); | ||
break; | ||
case CURL_SSLVERSION_TLSv1_0: | ||
(void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx, | ||
kTLSProtocol1, | ||
true); | ||
break; | ||
case CURL_SSLVERSION_TLSv1_1: | ||
(void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx, | ||
kTLSProtocol11, | ||
true); | ||
break; | ||
case CURL_SSLVERSION_TLSv1_2: | ||
(void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx, | ||
kTLSProtocol12, | ||
true); | ||
break; | ||
case CURL_SSLVERSION_TLSv1_3: | ||
failf(data, "DarwinSSL: TLS 1.3 is not yet supported"); | ||
return CURLE_SSL_CONNECT_ERROR; | ||
{ | ||
CURLcode result = set_ssl_version_up_to(conn, sockindex, | ||
conn->ssl_config.version, | ||
conn->ssl_config.version_up_to); | ||
if(result != CURLE_OK) | ||
return result; | ||
} break; | ||
case CURL_SSLVERSION_SSLv3: | ||
err = SSLSetProtocolVersionEnabled(connssl->ssl_ctx, | ||
kSSLProtocol3, | ||
|
@@ -1207,6 +1319,11 @@ static CURLcode darwinssl_connect_step1(struct connectdata *conn, | |
#endif /* CURL_SUPPORT_MAC_10_8 */ | ||
} | ||
#else | ||
if(conn->ssl_config.version_up_to != CURL_SSLVERSION_OR_UP_TO_NONE) { | ||
failf(data, "Your version of the OS does not support to set maximum" | ||
" SSL/TLS version"); | ||
return CURLE_SSL_CONNECT_ERROR; | ||
} | ||
(void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx, kSSLProtocolAll, false); | ||
switch(conn->ssl_config.version) { | ||
case CURL_SSLVERSION_DEFAULT: | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you recursively call the function? Would not it be enough to (re)assign
ssl_version_up_to
and continue the execution?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I will rewrite it as you suggest.