Debian Codegraph @

src/ssl.c

raw symbols SCIP
1 #include <curl/curl.h>
2 #include <Rinternals.h>
3
4 #if LIBCURL_VERSION_MAJOR > 7 || (LIBCURL_VERSION_MAJOR == 7 && LIBCURL_VERSION_MINOR >= 56)
5 #define HAS_MULTI_SSL 1
6 #endif
7
8 /* Force OpenSSL on Legacy Windows (Vista/2008) which do not support TLS 1.2 natively.
9 * On other systems we let libcurl choose so you can set the 'CURL_SSL_BACKEND' variable.
10 */
11 void switch_to_openssl_on_vista(void){
12 #if defined(_WIN32) && defined(HAS_MULTI_SSL)
13 /* If a CURL_SSL_BACKEND is set, do not override */
14 char *envvar = getenv("CURL_SSL_BACKEND");
15 if(envvar != NULL && *envvar != 0){
16 REprintf("Initiating curl with CURL_SSL_BACKEND: %s\n", envvar);
17 return;
18 }
19
20 /* Lookup Windows version */
21 DWORD dwBuild = 0;
22 DWORD dwVersion = GetVersion();
23 if (dwVersion < 0x80000000)
24 dwBuild = (DWORD)(HIWORD(dwVersion));
25
26 /* TLS 1.2 requires at least Windows 7 or 2008-R2 */
27 if(dwBuild < 7600){
28 switch(curl_global_sslset(CURLSSLBACKEND_OPENSSL, NULL, NULL)){
29 case CURLSSLSET_OK :
30 break;
31 case CURLSSLSET_TOO_LATE:
32 Rf_warning("Failed to set libcurl SSL: already initiated");
33 break;
34 case CURLSSLSET_UNKNOWN_BACKEND:
35 Rf_warning("Failed to set libcurl SSL: unsupported backend");
36 break;
37 default:
38 Rf_warning("Failed to set libcurl SSL: unknown error");
39 break;
40 }
41 }
42
43 #endif
44 }