vtls.c 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) 1998 - 2018, Daniel Stenberg, <[email protected]>, et al.
  9. *
  10. * This software is licensed as described in the file COPYING, which
  11. * you should have received as part of this distribution. The terms
  12. * are also available at https://curl.haxx.se/docs/copyright.html.
  13. *
  14. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. * copies of the Software, and permit persons to whom the Software is
  16. * furnished to do so, under the terms of the COPYING file.
  17. *
  18. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. * KIND, either express or implied.
  20. *
  21. ***************************************************************************/
  22. /* This file is for implementing all "generic" SSL functions that all libcurl
  23. internals should use. It is then responsible for calling the proper
  24. "backend" function.
  25. SSL-functions in libcurl should call functions in this source file, and not
  26. to any specific SSL-layer.
  27. Curl_ssl_ - prefix for generic ones
  28. Note that this source code uses the functions of the configured SSL
  29. backend via the global Curl_ssl instance.
  30. "SSL/TLS Strong Encryption: An Introduction"
  31. https://httpd.apache.org/docs/2.0/ssl/ssl_intro.html
  32. */
  33. #include "curl_setup.h"
  34. #ifdef HAVE_SYS_TYPES_H
  35. #include <sys/types.h>
  36. #endif
  37. #ifdef HAVE_SYS_STAT_H
  38. #include <sys/stat.h>
  39. #endif
  40. #ifdef HAVE_FCNTL_H
  41. #include <fcntl.h>
  42. #endif
  43. #include "urldata.h"
  44. #include "vtls.h" /* generic SSL protos etc */
  45. #include "slist.h"
  46. #include "sendf.h"
  47. #include "strcase.h"
  48. #include "url.h"
  49. #include "progress.h"
  50. #include "share.h"
  51. #include "multiif.h"
  52. #include "timeval.h"
  53. #include "curl_md5.h"
  54. #include "warnless.h"
  55. #include "curl_base64.h"
  56. #include "curl_printf.h"
  57. /* The last #include files should be: */
  58. #include "curl_memory.h"
  59. #include "memdebug.h"
  60. /* convenience macro to check if this handle is using a shared SSL session */
  61. #define SSLSESSION_SHARED(data) (data->share && \
  62. (data->share->specifier & \
  63. (1<<CURL_LOCK_DATA_SSL_SESSION)))
  64. #define CLONE_STRING(var) \
  65. if(source->var) { \
  66. dest->var = strdup(source->var); \
  67. if(!dest->var) \
  68. return FALSE; \
  69. } \
  70. else \
  71. dest->var = NULL;
  72. bool
  73. Curl_ssl_config_matches(struct ssl_primary_config* data,
  74. struct ssl_primary_config* needle)
  75. {
  76. if((data->version == needle->version) &&
  77. (data->version_max == needle->version_max) &&
  78. (data->verifypeer == needle->verifypeer) &&
  79. (data->verifyhost == needle->verifyhost) &&
  80. (data->verifystatus == needle->verifystatus) &&
  81. Curl_safe_strcasecompare(data->CApath, needle->CApath) &&
  82. Curl_safe_strcasecompare(data->CAfile, needle->CAfile) &&
  83. Curl_safe_strcasecompare(data->clientcert, needle->clientcert) &&
  84. Curl_safe_strcasecompare(data->random_file, needle->random_file) &&
  85. Curl_safe_strcasecompare(data->egdsocket, needle->egdsocket) &&
  86. Curl_safe_strcasecompare(data->cipher_list, needle->cipher_list))
  87. return TRUE;
  88. return FALSE;
  89. }
  90. bool
  91. Curl_clone_primary_ssl_config(struct ssl_primary_config *source,
  92. struct ssl_primary_config *dest)
  93. {
  94. dest->version = source->version;
  95. dest->version_max = source->version_max;
  96. dest->verifypeer = source->verifypeer;
  97. dest->verifyhost = source->verifyhost;
  98. dest->verifystatus = source->verifystatus;
  99. dest->sessionid = source->sessionid;
  100. CLONE_STRING(CApath);
  101. CLONE_STRING(CAfile);
  102. CLONE_STRING(clientcert);
  103. CLONE_STRING(random_file);
  104. CLONE_STRING(egdsocket);
  105. CLONE_STRING(cipher_list);
  106. return TRUE;
  107. }
  108. void Curl_free_primary_ssl_config(struct ssl_primary_config* sslc)
  109. {
  110. Curl_safefree(sslc->CApath);
  111. Curl_safefree(sslc->CAfile);
  112. Curl_safefree(sslc->clientcert);
  113. Curl_safefree(sslc->random_file);
  114. Curl_safefree(sslc->egdsocket);
  115. Curl_safefree(sslc->cipher_list);
  116. }
  117. #ifdef USE_SSL
  118. static int multissl_init(const struct Curl_ssl *backend);
  119. #endif
  120. int Curl_ssl_backend(void)
  121. {
  122. #ifdef USE_SSL
  123. multissl_init(NULL);
  124. return Curl_ssl->info.id;
  125. #else
  126. return (int)CURLSSLBACKEND_NONE;
  127. #endif
  128. }
  129. #ifdef USE_SSL
  130. /* "global" init done? */
  131. static bool init_ssl = FALSE;
  132. /**
  133. * Global SSL init
  134. *
  135. * @retval 0 error initializing SSL
  136. * @retval 1 SSL initialized successfully
  137. */
  138. int Curl_ssl_init(void)
  139. {
  140. /* make sure this is only done once */
  141. if(init_ssl)
  142. return 1;
  143. init_ssl = TRUE; /* never again */
  144. return Curl_ssl->init();
  145. }
  146. /* Global cleanup */
  147. void Curl_ssl_cleanup(void)
  148. {
  149. if(init_ssl) {
  150. /* only cleanup if we did a previous init */
  151. Curl_ssl->cleanup();
  152. init_ssl = FALSE;
  153. }
  154. }
  155. static bool ssl_prefs_check(struct Curl_easy *data)
  156. {
  157. /* check for CURLOPT_SSLVERSION invalid parameter value */
  158. const long sslver = data->set.ssl.primary.version;
  159. if((sslver < 0) || (sslver >= CURL_SSLVERSION_LAST)) {
  160. failf(data, "Unrecognized parameter value passed via CURLOPT_SSLVERSION");
  161. return FALSE;
  162. }
  163. switch(data->set.ssl.primary.version_max) {
  164. case CURL_SSLVERSION_MAX_NONE:
  165. case CURL_SSLVERSION_MAX_DEFAULT:
  166. break;
  167. default:
  168. if((data->set.ssl.primary.version_max >> 16) < sslver) {
  169. failf(data, "CURL_SSLVERSION_MAX incompatible with CURL_SSLVERSION");
  170. return FALSE;
  171. }
  172. }
  173. return TRUE;
  174. }
  175. static CURLcode
  176. ssl_connect_init_proxy(struct connectdata *conn, int sockindex)
  177. {
  178. DEBUGASSERT(conn->bits.proxy_ssl_connected[sockindex]);
  179. if(ssl_connection_complete == conn->ssl[sockindex].state &&
  180. !conn->proxy_ssl[sockindex].use) {
  181. struct ssl_backend_data *pbdata;
  182. if(!(Curl_ssl->supports & SSLSUPP_HTTPS_PROXY))
  183. return CURLE_NOT_BUILT_IN;
  184. /* The pointers to the ssl backend data, which is opaque here, are swapped
  185. rather than move the contents. */
  186. pbdata = conn->proxy_ssl[sockindex].backend;
  187. conn->proxy_ssl[sockindex] = conn->ssl[sockindex];
  188. memset(&conn->ssl[sockindex], 0, sizeof(conn->ssl[sockindex]));
  189. memset(pbdata, 0, Curl_ssl->sizeof_ssl_backend_data);
  190. conn->ssl[sockindex].backend = pbdata;
  191. }
  192. return CURLE_OK;
  193. }
  194. CURLcode
  195. Curl_ssl_connect(struct connectdata *conn, int sockindex)
  196. {
  197. CURLcode result;
  198. if(conn->bits.proxy_ssl_connected[sockindex]) {
  199. result = ssl_connect_init_proxy(conn, sockindex);
  200. if(result)
  201. return result;
  202. }
  203. if(!ssl_prefs_check(conn->data))
  204. return CURLE_SSL_CONNECT_ERROR;
  205. /* mark this is being ssl-enabled from here on. */
  206. conn->ssl[sockindex].use = TRUE;
  207. conn->ssl[sockindex].state = ssl_connection_negotiating;
  208. result = Curl_ssl->connect(conn, sockindex);
  209. if(!result)
  210. Curl_pgrsTime(conn->data, TIMER_APPCONNECT); /* SSL is connected */
  211. return result;
  212. }
  213. CURLcode
  214. Curl_ssl_connect_nonblocking(struct connectdata *conn, int sockindex,
  215. bool *done)
  216. {
  217. CURLcode result;
  218. if(conn->bits.proxy_ssl_connected[sockindex]) {
  219. result = ssl_connect_init_proxy(conn, sockindex);
  220. if(result)
  221. return result;
  222. }
  223. if(!ssl_prefs_check(conn->data))
  224. return CURLE_SSL_CONNECT_ERROR;
  225. /* mark this is being ssl requested from here on. */
  226. conn->ssl[sockindex].use = TRUE;
  227. result = Curl_ssl->connect_nonblocking(conn, sockindex, done);
  228. if(!result && *done)
  229. Curl_pgrsTime(conn->data, TIMER_APPCONNECT); /* SSL is connected */
  230. return result;
  231. }
  232. /*
  233. * Lock shared SSL session data
  234. */
  235. void Curl_ssl_sessionid_lock(struct connectdata *conn)
  236. {
  237. if(SSLSESSION_SHARED(conn->data))
  238. Curl_share_lock(conn->data,
  239. CURL_LOCK_DATA_SSL_SESSION, CURL_LOCK_ACCESS_SINGLE);
  240. }
  241. /*
  242. * Unlock shared SSL session data
  243. */
  244. void Curl_ssl_sessionid_unlock(struct connectdata *conn)
  245. {
  246. if(SSLSESSION_SHARED(conn->data))
  247. Curl_share_unlock(conn->data, CURL_LOCK_DATA_SSL_SESSION);
  248. }
  249. /*
  250. * Check if there's a session ID for the given connection in the cache, and if
  251. * there's one suitable, it is provided. Returns TRUE when no entry matched.
  252. */
  253. bool Curl_ssl_getsessionid(struct connectdata *conn,
  254. void **ssl_sessionid,
  255. size_t *idsize, /* set 0 if unknown */
  256. int sockindex)
  257. {
  258. struct curl_ssl_session *check;
  259. struct Curl_easy *data = conn->data;
  260. size_t i;
  261. long *general_age;
  262. bool no_match = TRUE;
  263. const bool isProxy = CONNECT_PROXY_SSL();
  264. struct ssl_primary_config * const ssl_config = isProxy ?
  265. &conn->proxy_ssl_config :
  266. &conn->ssl_config;
  267. const char * const name = isProxy ? conn->http_proxy.host.name :
  268. conn->host.name;
  269. int port = isProxy ? (int)conn->port : conn->remote_port;
  270. *ssl_sessionid = NULL;
  271. DEBUGASSERT(SSL_SET_OPTION(primary.sessionid));
  272. if(!SSL_SET_OPTION(primary.sessionid))
  273. /* session ID re-use is disabled */
  274. return TRUE;
  275. /* Lock if shared */
  276. if(SSLSESSION_SHARED(data))
  277. general_age = &data->share->sessionage;
  278. else
  279. general_age = &data->state.sessionage;
  280. for(i = 0; i < data->set.general_ssl.max_ssl_sessions; i++) {
  281. check = &data->state.session[i];
  282. if(!check->sessionid)
  283. /* not session ID means blank entry */
  284. continue;
  285. if(strcasecompare(name, check->name) &&
  286. ((!conn->bits.conn_to_host && !check->conn_to_host) ||
  287. (conn->bits.conn_to_host && check->conn_to_host &&
  288. strcasecompare(conn->conn_to_host.name, check->conn_to_host))) &&
  289. ((!conn->bits.conn_to_port && check->conn_to_port == -1) ||
  290. (conn->bits.conn_to_port && check->conn_to_port != -1 &&
  291. conn->conn_to_port == check->conn_to_port)) &&
  292. (port == check->remote_port) &&
  293. strcasecompare(conn->handler->scheme, check->scheme) &&
  294. Curl_ssl_config_matches(ssl_config, &check->ssl_config)) {
  295. /* yes, we have a session ID! */
  296. (*general_age)++; /* increase general age */
  297. check->age = *general_age; /* set this as used in this age */
  298. *ssl_sessionid = check->sessionid;
  299. if(idsize)
  300. *idsize = check->idsize;
  301. no_match = FALSE;
  302. break;
  303. }
  304. }
  305. return no_match;
  306. }
  307. /*
  308. * Kill a single session ID entry in the cache.
  309. */
  310. void Curl_ssl_kill_session(struct curl_ssl_session *session)
  311. {
  312. if(session->sessionid) {
  313. /* defensive check */
  314. /* free the ID the SSL-layer specific way */
  315. Curl_ssl->session_free(session->sessionid);
  316. session->sessionid = NULL;
  317. session->age = 0; /* fresh */
  318. Curl_free_primary_ssl_config(&session->ssl_config);
  319. Curl_safefree(session->name);
  320. Curl_safefree(session->conn_to_host);
  321. }
  322. }
  323. /*
  324. * Delete the given session ID from the cache.
  325. */
  326. void Curl_ssl_delsessionid(struct connectdata *conn, void *ssl_sessionid)
  327. {
  328. size_t i;
  329. struct Curl_easy *data = conn->data;
  330. for(i = 0; i < data->set.general_ssl.max_ssl_sessions; i++) {
  331. struct curl_ssl_session *check = &data->state.session[i];
  332. if(check->sessionid == ssl_sessionid) {
  333. Curl_ssl_kill_session(check);
  334. break;
  335. }
  336. }
  337. }
  338. /*
  339. * Store session id in the session cache. The ID passed on to this function
  340. * must already have been extracted and allocated the proper way for the SSL
  341. * layer. Curl_XXXX_session_free() will be called to free/kill the session ID
  342. * later on.
  343. */
  344. CURLcode Curl_ssl_addsessionid(struct connectdata *conn,
  345. void *ssl_sessionid,
  346. size_t idsize,
  347. int sockindex)
  348. {
  349. size_t i;
  350. struct Curl_easy *data = conn->data; /* the mother of all structs */
  351. struct curl_ssl_session *store = &data->state.session[0];
  352. long oldest_age = data->state.session[0].age; /* zero if unused */
  353. char *clone_host;
  354. char *clone_conn_to_host;
  355. int conn_to_port;
  356. long *general_age;
  357. const bool isProxy = CONNECT_PROXY_SSL();
  358. struct ssl_primary_config * const ssl_config = isProxy ?
  359. &conn->proxy_ssl_config :
  360. &conn->ssl_config;
  361. DEBUGASSERT(SSL_SET_OPTION(primary.sessionid));
  362. clone_host = strdup(isProxy ? conn->http_proxy.host.name : conn->host.name);
  363. if(!clone_host)
  364. return CURLE_OUT_OF_MEMORY; /* bail out */
  365. if(conn->bits.conn_to_host) {
  366. clone_conn_to_host = strdup(conn->conn_to_host.name);
  367. if(!clone_conn_to_host) {
  368. free(clone_host);
  369. return CURLE_OUT_OF_MEMORY; /* bail out */
  370. }
  371. }
  372. else
  373. clone_conn_to_host = NULL;
  374. if(conn->bits.conn_to_port)
  375. conn_to_port = conn->conn_to_port;
  376. else
  377. conn_to_port = -1;
  378. /* Now we should add the session ID and the host name to the cache, (remove
  379. the oldest if necessary) */
  380. /* If using shared SSL session, lock! */
  381. if(SSLSESSION_SHARED(data)) {
  382. general_age = &data->share->sessionage;
  383. }
  384. else {
  385. general_age = &data->state.sessionage;
  386. }
  387. /* find an empty slot for us, or find the oldest */
  388. for(i = 1; (i < data->set.general_ssl.max_ssl_sessions) &&
  389. data->state.session[i].sessionid; i++) {
  390. if(data->state.session[i].age < oldest_age) {
  391. oldest_age = data->state.session[i].age;
  392. store = &data->state.session[i];
  393. }
  394. }
  395. if(i == data->set.general_ssl.max_ssl_sessions)
  396. /* cache is full, we must "kill" the oldest entry! */
  397. Curl_ssl_kill_session(store);
  398. else
  399. store = &data->state.session[i]; /* use this slot */
  400. /* now init the session struct wisely */
  401. store->sessionid = ssl_sessionid;
  402. store->idsize = idsize;
  403. store->age = *general_age; /* set current age */
  404. /* free it if there's one already present */
  405. free(store->name);
  406. free(store->conn_to_host);
  407. store->name = clone_host; /* clone host name */
  408. store->conn_to_host = clone_conn_to_host; /* clone connect to host name */
  409. store->conn_to_port = conn_to_port; /* connect to port number */
  410. /* port number */
  411. store->remote_port = isProxy ? (int)conn->port : conn->remote_port;
  412. store->scheme = conn->handler->scheme;
  413. if(!Curl_clone_primary_ssl_config(ssl_config, &store->ssl_config)) {
  414. store->sessionid = NULL; /* let caller free sessionid */
  415. free(clone_host);
  416. free(clone_conn_to_host);
  417. return CURLE_OUT_OF_MEMORY;
  418. }
  419. return CURLE_OK;
  420. }
  421. void Curl_ssl_close_all(struct Curl_easy *data)
  422. {
  423. size_t i;
  424. /* kill the session ID cache if not shared */
  425. if(data->state.session && !SSLSESSION_SHARED(data)) {
  426. for(i = 0; i < data->set.general_ssl.max_ssl_sessions; i++)
  427. /* the single-killer function handles empty table slots */
  428. Curl_ssl_kill_session(&data->state.session[i]);
  429. /* free the cache data */
  430. Curl_safefree(data->state.session);
  431. }
  432. Curl_ssl->close_all(data);
  433. }
  434. #if defined(USE_OPENSSL) || defined(USE_GNUTLS) || defined(USE_SCHANNEL) || \
  435. defined(USE_DARWINSSL) || defined(USE_POLARSSL) || defined(USE_NSS) || \
  436. defined(USE_MBEDTLS) || defined(USE_CYASSL)
  437. int Curl_ssl_getsock(struct connectdata *conn, curl_socket_t *socks,
  438. int numsocks)
  439. {
  440. struct ssl_connect_data *connssl = &conn->ssl[FIRSTSOCKET];
  441. if(!numsocks)
  442. return GETSOCK_BLANK;
  443. if(connssl->connecting_state == ssl_connect_2_writing) {
  444. /* write mode */
  445. socks[0] = conn->sock[FIRSTSOCKET];
  446. return GETSOCK_WRITESOCK(0);
  447. }
  448. if(connssl->connecting_state == ssl_connect_2_reading) {
  449. /* read mode */
  450. socks[0] = conn->sock[FIRSTSOCKET];
  451. return GETSOCK_READSOCK(0);
  452. }
  453. return GETSOCK_BLANK;
  454. }
  455. #else
  456. int Curl_ssl_getsock(struct connectdata *conn,
  457. curl_socket_t *socks,
  458. int numsocks)
  459. {
  460. (void)conn;
  461. (void)socks;
  462. (void)numsocks;
  463. return GETSOCK_BLANK;
  464. }
  465. /* USE_OPENSSL || USE_GNUTLS || USE_SCHANNEL || USE_DARWINSSL || USE_NSS */
  466. #endif
  467. void Curl_ssl_close(struct connectdata *conn, int sockindex)
  468. {
  469. DEBUGASSERT((sockindex <= 1) && (sockindex >= -1));
  470. Curl_ssl->close_one(conn, sockindex);
  471. }
  472. CURLcode Curl_ssl_shutdown(struct connectdata *conn, int sockindex)
  473. {
  474. if(Curl_ssl->shutdown(conn, sockindex))
  475. return CURLE_SSL_SHUTDOWN_FAILED;
  476. conn->ssl[sockindex].use = FALSE; /* get back to ordinary socket usage */
  477. conn->ssl[sockindex].state = ssl_connection_none;
  478. conn->recv[sockindex] = Curl_recv_plain;
  479. conn->send[sockindex] = Curl_send_plain;
  480. return CURLE_OK;
  481. }
  482. /* Selects an SSL crypto engine
  483. */
  484. CURLcode Curl_ssl_set_engine(struct Curl_easy *data, const char *engine)
  485. {
  486. return Curl_ssl->set_engine(data, engine);
  487. }
  488. /* Selects the default SSL crypto engine
  489. */
  490. CURLcode Curl_ssl_set_engine_default(struct Curl_easy *data)
  491. {
  492. return Curl_ssl->set_engine_default(data);
  493. }
  494. /* Return list of OpenSSL crypto engine names. */
  495. struct curl_slist *Curl_ssl_engines_list(struct Curl_easy *data)
  496. {
  497. return Curl_ssl->engines_list(data);
  498. }
  499. /*
  500. * This sets up a session ID cache to the specified size. Make sure this code
  501. * is agnostic to what underlying SSL technology we use.
  502. */
  503. CURLcode Curl_ssl_initsessions(struct Curl_easy *data, size_t amount)
  504. {
  505. struct curl_ssl_session *session;
  506. if(data->state.session)
  507. /* this is just a precaution to prevent multiple inits */
  508. return CURLE_OK;
  509. session = calloc(amount, sizeof(struct curl_ssl_session));
  510. if(!session)
  511. return CURLE_OUT_OF_MEMORY;
  512. /* store the info in the SSL section */
  513. data->set.general_ssl.max_ssl_sessions = amount;
  514. data->state.session = session;
  515. data->state.sessionage = 1; /* this is brand new */
  516. return CURLE_OK;
  517. }
  518. static size_t Curl_multissl_version(char *buffer, size_t size);
  519. size_t Curl_ssl_version(char *buffer, size_t size)
  520. {
  521. #ifdef CURL_WITH_MULTI_SSL
  522. return Curl_multissl_version(buffer, size);
  523. #else
  524. return Curl_ssl->version(buffer, size);
  525. #endif
  526. }
  527. /*
  528. * This function tries to determine connection status.
  529. *
  530. * Return codes:
  531. * 1 means the connection is still in place
  532. * 0 means the connection has been closed
  533. * -1 means the connection status is unknown
  534. */
  535. int Curl_ssl_check_cxn(struct connectdata *conn)
  536. {
  537. return Curl_ssl->check_cxn(conn);
  538. }
  539. bool Curl_ssl_data_pending(const struct connectdata *conn,
  540. int connindex)
  541. {
  542. return Curl_ssl->data_pending(conn, connindex);
  543. }
  544. void Curl_ssl_free_certinfo(struct Curl_easy *data)
  545. {
  546. int i;
  547. struct curl_certinfo *ci = &data->info.certs;
  548. if(ci->num_of_certs) {
  549. /* free all individual lists used */
  550. for(i = 0; i<ci->num_of_certs; i++) {
  551. curl_slist_free_all(ci->certinfo[i]);
  552. ci->certinfo[i] = NULL;
  553. }
  554. free(ci->certinfo); /* free the actual array too */
  555. ci->certinfo = NULL;
  556. ci->num_of_certs = 0;
  557. }
  558. }
  559. CURLcode Curl_ssl_init_certinfo(struct Curl_easy *data, int num)
  560. {
  561. struct curl_certinfo *ci = &data->info.certs;
  562. struct curl_slist **table;
  563. /* Free any previous certificate information structures */
  564. Curl_ssl_free_certinfo(data);
  565. /* Allocate the required certificate information structures */
  566. table = calloc((size_t) num, sizeof(struct curl_slist *));
  567. if(!table)
  568. return CURLE_OUT_OF_MEMORY;
  569. ci->num_of_certs = num;
  570. ci->certinfo = table;
  571. return CURLE_OK;
  572. }
  573. /*
  574. * 'value' is NOT a zero terminated string
  575. */
  576. CURLcode Curl_ssl_push_certinfo_len(struct Curl_easy *data,
  577. int certnum,
  578. const char *label,
  579. const char *value,
  580. size_t valuelen)
  581. {
  582. struct curl_certinfo *ci = &data->info.certs;
  583. char *output;
  584. struct curl_slist *nl;
  585. CURLcode result = CURLE_OK;
  586. size_t labellen = strlen(label);
  587. size_t outlen = labellen + 1 + valuelen + 1; /* label:value\0 */
  588. output = malloc(outlen);
  589. if(!output)
  590. return CURLE_OUT_OF_MEMORY;
  591. /* sprintf the label and colon */
  592. snprintf(output, outlen, "%s:", label);
  593. /* memcpy the value (it might not be zero terminated) */
  594. memcpy(&output[labellen + 1], value, valuelen);
  595. /* zero terminate the output */
  596. output[labellen + 1 + valuelen] = 0;
  597. nl = Curl_slist_append_nodup(ci->certinfo[certnum], output);
  598. if(!nl) {
  599. free(output);
  600. curl_slist_free_all(ci->certinfo[certnum]);
  601. result = CURLE_OUT_OF_MEMORY;
  602. }
  603. ci->certinfo[certnum] = nl;
  604. return result;
  605. }
  606. /*
  607. * This is a convenience function for push_certinfo_len that takes a zero
  608. * terminated value.
  609. */
  610. CURLcode Curl_ssl_push_certinfo(struct Curl_easy *data,
  611. int certnum,
  612. const char *label,
  613. const char *value)
  614. {
  615. size_t valuelen = strlen(value);
  616. return Curl_ssl_push_certinfo_len(data, certnum, label, value, valuelen);
  617. }
  618. CURLcode Curl_ssl_random(struct Curl_easy *data,
  619. unsigned char *entropy,
  620. size_t length)
  621. {
  622. return Curl_ssl->random(data, entropy, length);
  623. }
  624. /*
  625. * Public key pem to der conversion
  626. */
  627. static CURLcode pubkey_pem_to_der(const char *pem,
  628. unsigned char **der, size_t *der_len)
  629. {
  630. char *stripped_pem, *begin_pos, *end_pos;
  631. size_t pem_count, stripped_pem_count = 0, pem_len;
  632. CURLcode result;
  633. /* if no pem, exit. */
  634. if(!pem)
  635. return CURLE_BAD_CONTENT_ENCODING;
  636. begin_pos = strstr(pem, "-----BEGIN PUBLIC KEY-----");
  637. if(!begin_pos)
  638. return CURLE_BAD_CONTENT_ENCODING;
  639. pem_count = begin_pos - pem;
  640. /* Invalid if not at beginning AND not directly following \n */
  641. if(0 != pem_count && '\n' != pem[pem_count - 1])
  642. return CURLE_BAD_CONTENT_ENCODING;
  643. /* 26 is length of "-----BEGIN PUBLIC KEY-----" */
  644. pem_count += 26;
  645. /* Invalid if not directly following \n */
  646. end_pos = strstr(pem + pem_count, "\n-----END PUBLIC KEY-----");
  647. if(!end_pos)
  648. return CURLE_BAD_CONTENT_ENCODING;
  649. pem_len = end_pos - pem;
  650. stripped_pem = malloc(pem_len - pem_count + 1);
  651. if(!stripped_pem)
  652. return CURLE_OUT_OF_MEMORY;
  653. /*
  654. * Here we loop through the pem array one character at a time between the
  655. * correct indices, and place each character that is not '\n' or '\r'
  656. * into the stripped_pem array, which should represent the raw base64 string
  657. */
  658. while(pem_count < pem_len) {
  659. if('\n' != pem[pem_count] && '\r' != pem[pem_count])
  660. stripped_pem[stripped_pem_count++] = pem[pem_count];
  661. ++pem_count;
  662. }
  663. /* Place the null terminator in the correct place */
  664. stripped_pem[stripped_pem_count] = '\0';
  665. result = Curl_base64_decode(stripped_pem, der, der_len);
  666. Curl_safefree(stripped_pem);
  667. return result;
  668. }
  669. /*
  670. * Generic pinned public key check.
  671. */
  672. CURLcode Curl_pin_peer_pubkey(struct Curl_easy *data,
  673. const char *pinnedpubkey,
  674. const unsigned char *pubkey, size_t pubkeylen)
  675. {
  676. FILE *fp;
  677. unsigned char *buf = NULL, *pem_ptr = NULL;
  678. long filesize;
  679. size_t size, pem_len;
  680. CURLcode pem_read;
  681. CURLcode result = CURLE_SSL_PINNEDPUBKEYNOTMATCH;
  682. CURLcode encode;
  683. size_t encodedlen, pinkeylen;
  684. char *encoded, *pinkeycopy, *begin_pos, *end_pos;
  685. unsigned char *sha256sumdigest = NULL;
  686. /* if a path wasn't specified, don't pin */
  687. if(!pinnedpubkey)
  688. return CURLE_OK;
  689. if(!pubkey || !pubkeylen)
  690. return result;
  691. /* only do this if pinnedpubkey starts with "sha256//", length 8 */
  692. if(strncmp(pinnedpubkey, "sha256//", 8) == 0) {
  693. if(!Curl_ssl->sha256sum) {
  694. /* without sha256 support, this cannot match */
  695. return result;
  696. }
  697. /* compute sha256sum of public key */
  698. sha256sumdigest = malloc(CURL_SHA256_DIGEST_LENGTH);
  699. if(!sha256sumdigest)
  700. return CURLE_OUT_OF_MEMORY;
  701. encode = Curl_ssl->sha256sum(pubkey, pubkeylen,
  702. sha256sumdigest, CURL_SHA256_DIGEST_LENGTH);
  703. if(encode != CURLE_OK)
  704. return encode;
  705. encode = Curl_base64_encode(data, (char *)sha256sumdigest,
  706. CURL_SHA256_DIGEST_LENGTH, &encoded,
  707. &encodedlen);
  708. Curl_safefree(sha256sumdigest);
  709. if(encode)
  710. return encode;
  711. infof(data, "\t public key hash: sha256//%s\n", encoded);
  712. /* it starts with sha256//, copy so we can modify it */
  713. pinkeylen = strlen(pinnedpubkey) + 1;
  714. pinkeycopy = malloc(pinkeylen);
  715. if(!pinkeycopy) {
  716. Curl_safefree(encoded);
  717. return CURLE_OUT_OF_MEMORY;
  718. }
  719. memcpy(pinkeycopy, pinnedpubkey, pinkeylen);
  720. /* point begin_pos to the copy, and start extracting keys */
  721. begin_pos = pinkeycopy;
  722. do {
  723. end_pos = strstr(begin_pos, ";sha256//");
  724. /*
  725. * if there is an end_pos, null terminate,
  726. * otherwise it'll go to the end of the original string
  727. */
  728. if(end_pos)
  729. end_pos[0] = '\0';
  730. /* compare base64 sha256 digests, 8 is the length of "sha256//" */
  731. if(encodedlen == strlen(begin_pos + 8) &&
  732. !memcmp(encoded, begin_pos + 8, encodedlen)) {
  733. result = CURLE_OK;
  734. break;
  735. }
  736. /*
  737. * change back the null-terminator we changed earlier,
  738. * and look for next begin
  739. */
  740. if(end_pos) {
  741. end_pos[0] = ';';
  742. begin_pos = strstr(end_pos, "sha256//");
  743. }
  744. } while(end_pos && begin_pos);
  745. Curl_safefree(encoded);
  746. Curl_safefree(pinkeycopy);
  747. return result;
  748. }
  749. fp = fopen(pinnedpubkey, "rb");
  750. if(!fp)
  751. return result;
  752. do {
  753. /* Determine the file's size */
  754. if(fseek(fp, 0, SEEK_END))
  755. break;
  756. filesize = ftell(fp);
  757. if(fseek(fp, 0, SEEK_SET))
  758. break;
  759. if(filesize < 0 || filesize > MAX_PINNED_PUBKEY_SIZE)
  760. break;
  761. /*
  762. * if the size of our certificate is bigger than the file
  763. * size then it can't match
  764. */
  765. size = curlx_sotouz((curl_off_t) filesize);
  766. if(pubkeylen > size)
  767. break;
  768. /*
  769. * Allocate buffer for the pinned key
  770. * With 1 additional byte for null terminator in case of PEM key
  771. */
  772. buf = malloc(size + 1);
  773. if(!buf)
  774. break;
  775. /* Returns number of elements read, which should be 1 */
  776. if((int) fread(buf, size, 1, fp) != 1)
  777. break;
  778. /* If the sizes are the same, it can't be base64 encoded, must be der */
  779. if(pubkeylen == size) {
  780. if(!memcmp(pubkey, buf, pubkeylen))
  781. result = CURLE_OK;
  782. break;
  783. }
  784. /*
  785. * Otherwise we will assume it's PEM and try to decode it
  786. * after placing null terminator
  787. */
  788. buf[size] = '\0';
  789. pem_read = pubkey_pem_to_der((const char *)buf, &pem_ptr, &pem_len);
  790. /* if it wasn't read successfully, exit */
  791. if(pem_read)
  792. break;
  793. /*
  794. * if the size of our certificate doesn't match the size of
  795. * the decoded file, they can't be the same, otherwise compare
  796. */
  797. if(pubkeylen == pem_len && !memcmp(pubkey, pem_ptr, pubkeylen))
  798. result = CURLE_OK;
  799. } while(0);
  800. Curl_safefree(buf);
  801. Curl_safefree(pem_ptr);
  802. fclose(fp);
  803. return result;
  804. }
  805. #ifndef CURL_DISABLE_CRYPTO_AUTH
  806. CURLcode Curl_ssl_md5sum(unsigned char *tmp, /* input */
  807. size_t tmplen,
  808. unsigned char *md5sum, /* output */
  809. size_t md5len)
  810. {
  811. return Curl_ssl->md5sum(tmp, tmplen, md5sum, md5len);
  812. }
  813. #endif
  814. /*
  815. * Check whether the SSL backend supports the status_request extension.
  816. */
  817. bool Curl_ssl_cert_status_request(void)
  818. {
  819. return Curl_ssl->cert_status_request();
  820. }
  821. /*
  822. * Check whether the SSL backend supports false start.
  823. */
  824. bool Curl_ssl_false_start(void)
  825. {
  826. return Curl_ssl->false_start();
  827. }
  828. /*
  829. * Default implementations for unsupported functions.
  830. */
  831. int Curl_none_init(void)
  832. {
  833. return 1;
  834. }
  835. void Curl_none_cleanup(void)
  836. { }
  837. int Curl_none_shutdown(struct connectdata *conn UNUSED_PARAM,
  838. int sockindex UNUSED_PARAM)
  839. {
  840. (void)conn;
  841. (void)sockindex;
  842. return 0;
  843. }
  844. int Curl_none_check_cxn(struct connectdata *conn UNUSED_PARAM)
  845. {
  846. (void)conn;
  847. return -1;
  848. }
  849. CURLcode Curl_none_random(struct Curl_easy *data UNUSED_PARAM,
  850. unsigned char *entropy UNUSED_PARAM,
  851. size_t length UNUSED_PARAM)
  852. {
  853. (void)data;
  854. (void)entropy;
  855. (void)length;
  856. return CURLE_NOT_BUILT_IN;
  857. }
  858. void Curl_none_close_all(struct Curl_easy *data UNUSED_PARAM)
  859. {
  860. (void)data;
  861. }
  862. void Curl_none_session_free(void *ptr UNUSED_PARAM)
  863. {
  864. (void)ptr;
  865. }
  866. bool Curl_none_data_pending(const struct connectdata *conn UNUSED_PARAM,
  867. int connindex UNUSED_PARAM)
  868. {
  869. (void)conn;
  870. (void)connindex;
  871. return 0;
  872. }
  873. bool Curl_none_cert_status_request(void)
  874. {
  875. return FALSE;
  876. }
  877. CURLcode Curl_none_set_engine(struct Curl_easy *data UNUSED_PARAM,
  878. const char *engine UNUSED_PARAM)
  879. {
  880. (void)data;
  881. (void)engine;
  882. return CURLE_NOT_BUILT_IN;
  883. }
  884. CURLcode Curl_none_set_engine_default(struct Curl_easy *data UNUSED_PARAM)
  885. {
  886. (void)data;
  887. return CURLE_NOT_BUILT_IN;
  888. }
  889. struct curl_slist *Curl_none_engines_list(struct Curl_easy *data UNUSED_PARAM)
  890. {
  891. (void)data;
  892. return (struct curl_slist *)NULL;
  893. }
  894. bool Curl_none_false_start(void)
  895. {
  896. return FALSE;
  897. }
  898. #ifndef CURL_DISABLE_CRYPTO_AUTH
  899. CURLcode Curl_none_md5sum(unsigned char *input, size_t inputlen,
  900. unsigned char *md5sum, size_t md5len UNUSED_PARAM)
  901. {
  902. MD5_context *MD5pw;
  903. (void)md5len;
  904. MD5pw = Curl_MD5_init(Curl_DIGEST_MD5);
  905. if(!MD5pw)
  906. return CURLE_OUT_OF_MEMORY;
  907. Curl_MD5_update(MD5pw, input, curlx_uztoui(inputlen));
  908. Curl_MD5_final(MD5pw, md5sum);
  909. return CURLE_OK;
  910. }
  911. #else
  912. CURLcode Curl_none_md5sum(unsigned char *input UNUSED_PARAM,
  913. size_t inputlen UNUSED_PARAM,
  914. unsigned char *md5sum UNUSED_PARAM,
  915. size_t md5len UNUSED_PARAM)
  916. {
  917. (void)input;
  918. (void)inputlen;
  919. (void)md5sum;
  920. (void)md5len;
  921. return CURLE_NOT_BUILT_IN;
  922. }
  923. #endif
  924. static int Curl_multissl_init(void)
  925. {
  926. if(multissl_init(NULL))
  927. return 1;
  928. return Curl_ssl->init();
  929. }
  930. static CURLcode Curl_multissl_connect(struct connectdata *conn, int sockindex)
  931. {
  932. if(multissl_init(NULL))
  933. return CURLE_FAILED_INIT;
  934. return Curl_ssl->connect(conn, sockindex);
  935. }
  936. static CURLcode Curl_multissl_connect_nonblocking(struct connectdata *conn,
  937. int sockindex, bool *done)
  938. {
  939. if(multissl_init(NULL))
  940. return CURLE_FAILED_INIT;
  941. return Curl_ssl->connect_nonblocking(conn, sockindex, done);
  942. }
  943. static void *Curl_multissl_get_internals(struct ssl_connect_data *connssl,
  944. CURLINFO info)
  945. {
  946. if(multissl_init(NULL))
  947. return NULL;
  948. return Curl_ssl->get_internals(connssl, info);
  949. }
  950. static void Curl_multissl_close(struct connectdata *conn, int sockindex)
  951. {
  952. if(multissl_init(NULL))
  953. return;
  954. Curl_ssl->close_one(conn, sockindex);
  955. }
  956. static const struct Curl_ssl Curl_ssl_multi = {
  957. { CURLSSLBACKEND_NONE, "multi" }, /* info */
  958. 0, /* supports nothing */
  959. (size_t)-1, /* something insanely large to be on the safe side */
  960. Curl_multissl_init, /* init */
  961. Curl_none_cleanup, /* cleanup */
  962. Curl_multissl_version, /* version */
  963. Curl_none_check_cxn, /* check_cxn */
  964. Curl_none_shutdown, /* shutdown */
  965. Curl_none_data_pending, /* data_pending */
  966. Curl_none_random, /* random */
  967. Curl_none_cert_status_request, /* cert_status_request */
  968. Curl_multissl_connect, /* connect */
  969. Curl_multissl_connect_nonblocking, /* connect_nonblocking */
  970. Curl_multissl_get_internals, /* get_internals */
  971. Curl_multissl_close, /* close_one */
  972. Curl_none_close_all, /* close_all */
  973. Curl_none_session_free, /* session_free */
  974. Curl_none_set_engine, /* set_engine */
  975. Curl_none_set_engine_default, /* set_engine_default */
  976. Curl_none_engines_list, /* engines_list */
  977. Curl_none_false_start, /* false_start */
  978. Curl_none_md5sum, /* md5sum */
  979. NULL /* sha256sum */
  980. };
  981. const struct Curl_ssl *Curl_ssl =
  982. #if defined(CURL_WITH_MULTI_SSL)
  983. &Curl_ssl_multi;
  984. #elif defined(USE_AXTLS)
  985. &Curl_ssl_axtls;
  986. #elif defined(USE_CYASSL)
  987. &Curl_ssl_cyassl;
  988. #elif defined(USE_DARWINSSL)
  989. &Curl_ssl_darwinssl;
  990. #elif defined(USE_GNUTLS)
  991. &Curl_ssl_gnutls;
  992. #elif defined(USE_GSKIT)
  993. &Curl_ssl_gskit;
  994. #elif defined(USE_MBEDTLS)
  995. &Curl_ssl_mbedtls;
  996. #elif defined(USE_NSS)
  997. &Curl_ssl_nss;
  998. #elif defined(USE_OPENSSL)
  999. &Curl_ssl_openssl;
  1000. #elif defined(USE_POLARSSL)
  1001. &Curl_ssl_polarssl;
  1002. #elif defined(USE_SCHANNEL)
  1003. &Curl_ssl_schannel;
  1004. #else
  1005. #error "Missing struct Curl_ssl for selected SSL backend"
  1006. #endif
  1007. static const struct Curl_ssl *available_backends[] = {
  1008. #if defined(USE_AXTLS)
  1009. &Curl_ssl_axtls,
  1010. #endif
  1011. #if defined(USE_CYASSL)
  1012. &Curl_ssl_cyassl,
  1013. #endif
  1014. #if defined(USE_DARWINSSL)
  1015. &Curl_ssl_darwinssl,
  1016. #endif
  1017. #if defined(USE_GNUTLS)
  1018. &Curl_ssl_gnutls,
  1019. #endif
  1020. #if defined(USE_GSKIT)
  1021. &Curl_ssl_gskit,
  1022. #endif
  1023. #if defined(USE_MBEDTLS)
  1024. &Curl_ssl_mbedtls,
  1025. #endif
  1026. #if defined(USE_NSS)
  1027. &Curl_ssl_nss,
  1028. #endif
  1029. #if defined(USE_OPENSSL)
  1030. &Curl_ssl_openssl,
  1031. #endif
  1032. #if defined(USE_POLARSSL)
  1033. &Curl_ssl_polarssl,
  1034. #endif
  1035. #if defined(USE_SCHANNEL)
  1036. &Curl_ssl_schannel,
  1037. #endif
  1038. NULL
  1039. };
  1040. static size_t Curl_multissl_version(char *buffer, size_t size)
  1041. {
  1042. static const struct Curl_ssl *selected;
  1043. static char backends[200];
  1044. static size_t total;
  1045. const struct Curl_ssl *current;
  1046. current = Curl_ssl == &Curl_ssl_multi ? available_backends[0] : Curl_ssl;
  1047. if(current != selected) {
  1048. char *p = backends;
  1049. int i;
  1050. selected = current;
  1051. for(i = 0; available_backends[i]; i++) {
  1052. if(i)
  1053. *(p++) = ' ';
  1054. if(selected != available_backends[i])
  1055. *(p++) = '(';
  1056. p += available_backends[i]->version(p, backends + sizeof(backends) - p);
  1057. if(selected != available_backends[i])
  1058. *(p++) = ')';
  1059. }
  1060. *p = '\0';
  1061. total = p - backends;
  1062. }
  1063. if(size < total)
  1064. memcpy(buffer, backends, total + 1);
  1065. else {
  1066. memcpy(buffer, backends, size - 1);
  1067. buffer[size - 1] = '\0';
  1068. }
  1069. return total;
  1070. }
  1071. static int multissl_init(const struct Curl_ssl *backend)
  1072. {
  1073. const char *env;
  1074. char *env_tmp;
  1075. int i;
  1076. if(Curl_ssl != &Curl_ssl_multi)
  1077. return 1;
  1078. if(backend) {
  1079. Curl_ssl = backend;
  1080. return 0;
  1081. }
  1082. if(!available_backends[0])
  1083. return 1;
  1084. env = env_tmp = curl_getenv("CURL_SSL_BACKEND");
  1085. #ifdef CURL_DEFAULT_SSL_BACKEND
  1086. if(!env)
  1087. env = CURL_DEFAULT_SSL_BACKEND;
  1088. #endif
  1089. if(env) {
  1090. for(i = 0; available_backends[i]; i++) {
  1091. if(strcasecompare(env, available_backends[i]->info.name)) {
  1092. Curl_ssl = available_backends[i];
  1093. curl_free(env_tmp);
  1094. return 0;
  1095. }
  1096. }
  1097. }
  1098. /* Fall back to first available backend */
  1099. Curl_ssl = available_backends[0];
  1100. curl_free(env_tmp);
  1101. return 0;
  1102. }
  1103. CURLsslset curl_global_sslset(curl_sslbackend id, const char *name,
  1104. const curl_ssl_backend ***avail)
  1105. {
  1106. int i;
  1107. if(avail)
  1108. *avail = (const curl_ssl_backend **)&available_backends;
  1109. if(Curl_ssl != &Curl_ssl_multi)
  1110. return id == Curl_ssl->info.id ? CURLSSLSET_OK : CURLSSLSET_TOO_LATE;
  1111. for(i = 0; available_backends[i]; i++) {
  1112. if(available_backends[i]->info.id == id ||
  1113. (name && strcasecompare(available_backends[i]->info.name, name))) {
  1114. multissl_init(available_backends[i]);
  1115. return CURLSSLSET_OK;
  1116. }
  1117. }
  1118. return CURLSSLSET_UNKNOWN_BACKEND;
  1119. }
  1120. #else /* USE_SSL */
  1121. CURLsslset curl_global_sslset(curl_sslbackend id, const char *name,
  1122. const curl_ssl_backend ***avail)
  1123. {
  1124. (void)id;
  1125. (void)name;
  1126. (void)avail;
  1127. return CURLSSLSET_NO_BACKENDS;
  1128. }
  1129. #endif /* !USE_SSL */