curl_easy_ssls_import.md (2157B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: curl_easy_ssls_import 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_SHARE (3) 9 - curl_share_setopt (3) 10 - curl_easy_ssls_export (3) 11 Protocol: 12 - TLS 13 TLS-backend: 14 - GnuTLS 15 - OpenSSL 16 - wolfSSL 17 - mbedTLS 18 Added-in: 8.12.0 19 --- 20 21 # NAME 22 23 curl_easy_ssls_export - export SSL sessions 24 25 # SYNOPSIS 26 27 ~~~c 28 #include <curl/curl.h> 29 30 CURLcode curl_easy_ssls_import(CURL *handle, 31 const char *session_key, 32 const unsigned char *shmac, size_t shmac_len, 33 const unsigned char *sdata, size_t sdata_len); 34 ~~~ 35 36 # DESCRIPTION 37 38 This function imports a previously exported SSL session ticket. **sdata** and 39 **sdata_len** must always be provided. If **session_key** is **NULL**, then 40 **shmac** and **shmac_len** must be given as received during the export. 41 See curl_easy_ssls_export(3) for a description of those. 42 43 Import of session tickets from other curl versions may fail due to changes 44 in the handling of **shmac** or **sdata**. A session ticket which has 45 already expired is silently discarded. 46 47 # %PROTOCOLS% 48 49 # EXAMPLE 50 51 ~~~c 52 int main(void) 53 { 54 CURLSHcode sh; 55 CURLSH *share = curl_share_init(); 56 CURLcode rc; 57 CURL *curl; 58 59 sh = curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION); 60 if(sh) 61 printf("Error: %s\n", curl_share_strerror(sh)); 62 63 curl = curl_easy_init(); 64 if(curl) { 65 extern unsigned char *shmac, *sdata; 66 size_t hlen = 4, slen = 5; 67 68 curl_easy_setopt(curl, CURLOPT_SHARE, share); 69 70 /* read shmac and sdata from storage */ 71 rc = curl_easy_ssls_import(curl, NULL, shmac, hlen, sdata, slen); 72 73 /* always cleanup */ 74 curl_easy_cleanup(curl); 75 } 76 curl_share_cleanup(share); 77 } 78 ~~~ 79 80 # %AVAILABILITY% 81 82 # RETURN VALUE 83 84 This function returns a CURLcode indicating success or error. 85 86 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 87 libcurl-errors(3). If CURLOPT_ERRORBUFFER(3) was set with curl_easy_setopt(3) 88 there can be an error message stored in the error buffer when non-zero is 89 returned.