CURLOPT_SSLVERSION.md (3710B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_SSLVERSION 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_HTTP_VERSION (3) 9 - CURLOPT_IPRESOLVE (3) 10 - CURLOPT_PROXY_SSLVERSION (3) 11 - CURLOPT_USE_SSL (3) 12 Protocol: 13 - TLS 14 TLS-backend: 15 - All 16 Added-in: 7.1 17 --- 18 19 # NAME 20 21 CURLOPT_SSLVERSION - preferred TLS/SSL version 22 23 # SYNOPSIS 24 25 ~~~c 26 #include <curl/curl.h> 27 28 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSLVERSION, long version); 29 ~~~ 30 31 # DESCRIPTION 32 33 Pass a long as parameter to control which version range of SSL/TLS versions to 34 use. 35 36 The SSL and TLS versions have typically developed from the most insecure 37 version to be more and more secure in this order through history: SSL v2, 38 SSLv3, TLS v1.0, TLS v1.1, TLS v1.2 and the most recent TLS v1.3. 39 40 Use one of the available defines for this purpose. The available options are: 41 42 ## CURL_SSLVERSION_DEFAULT 43 44 The default acceptable version range. The minimum acceptable version is by 45 default TLS v1.0 since 7.39.0 (unless the TLS library has a stricter rule). 46 47 ## CURL_SSLVERSION_TLSv1 48 49 TLS v1.0 or later 50 51 ## CURL_SSLVERSION_SSLv2 52 53 SSL v2 - refused 54 55 ## CURL_SSLVERSION_SSLv3 56 57 SSL v3 - refused 58 59 ## CURL_SSLVERSION_TLSv1_0 60 61 TLS v1.0 or later (Added in 7.34.0) 62 63 ## CURL_SSLVERSION_TLSv1_1 64 65 TLS v1.1 or later (Added in 7.34.0) 66 67 ## CURL_SSLVERSION_TLSv1_2 68 69 TLS v1.2 or later (Added in 7.34.0) 70 71 ## CURL_SSLVERSION_TLSv1_3 72 73 TLS v1.3 or later (Added in 7.52.0) 74 75 ## 76 77 The maximum TLS version can be set by using *one* of the 78 CURL_SSLVERSION_MAX_ macros below. It is also possible to OR *one* of the 79 CURL_SSLVERSION_ macros with *one* of the CURL_SSLVERSION_MAX_ macros. 80 81 ## CURL_SSLVERSION_MAX_DEFAULT 82 83 The flag defines the maximum supported TLS version by libcurl, or the default 84 value from the SSL library is used. libcurl uses a sensible default maximum, 85 which was TLS v1.2 up to before 7.61.0 and is TLS v1.3 since then - assuming 86 the TLS library support it. (Added in 7.54.0) 87 88 ## CURL_SSLVERSION_MAX_TLSv1_0 89 90 The flag defines maximum supported TLS version as TLS v1.0. 91 (Added in 7.54.0) 92 93 ## CURL_SSLVERSION_MAX_TLSv1_1 94 95 The flag defines maximum supported TLS version as TLS v1.1. 96 (Added in 7.54.0) 97 98 ## CURL_SSLVERSION_MAX_TLSv1_2 99 100 The flag defines maximum supported TLS version as TLS v1.2. 101 (Added in 7.54.0) 102 103 ## CURL_SSLVERSION_MAX_TLSv1_3 104 105 The flag defines maximum supported TLS version as TLS v1.3. 106 (Added in 7.54.0) 107 108 ## 109 110 In versions of curl prior to 7.54 the CURL_SSLVERSION_TLS options were 111 documented to allow *only* the specified TLS version, but behavior was 112 inconsistent depending on the TLS library. 113 114 # DEFAULT 115 116 CURL_SSLVERSION_DEFAULT 117 118 # %PROTOCOLS% 119 120 # EXAMPLE 121 122 ~~~c 123 int main(void) 124 { 125 CURL *curl = curl_easy_init(); 126 if(curl) { 127 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 128 129 /* ask libcurl to use TLS version 1.0 or later */ 130 curl_easy_setopt(curl, CURLOPT_SSLVERSION, (long)CURL_SSLVERSION_TLSv1); 131 132 /* Perform the request */ 133 curl_easy_perform(curl); 134 } 135 } 136 ~~~ 137 138 # HISTORY 139 140 SSLv2 is disabled by default since 7.18.1. Other SSL versions availability may 141 vary depending on which backend libcurl has been built to use. 142 143 SSLv3 is disabled by default since 7.39.0. 144 145 SSLv2 and SSLv3 are refused completely since curl 7.77.0 146 147 Since 8.10.0 wolfSSL is fully supported. Before 8.10.0 the MAX macros were not 148 supported with wolfSSL and the other macros did not set a minimum, but 149 restricted the TLS version to only the specified one. 150 151 Rustls support added in 8.10.0. 152 153 # %AVAILABILITY% 154 155 # RETURN VALUE 156 157 curl_easy_setopt(3) returns a CURLcode indicating success or error. 158 159 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 160 libcurl-errors(3).