wolfssl.c 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) 1998 - 2021, 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.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. /*
  23. * Source file for all wolfSSL specific code for the TLS/SSL layer. No code
  24. * but vtls.c should ever call or use these functions.
  25. *
  26. */
  27. #include "curl_setup.h"
  28. #ifdef USE_WOLFSSL
  29. #define WOLFSSL_OPTIONS_IGNORE_SYS
  30. #include <wolfssl/version.h>
  31. #include <wolfssl/options.h>
  32. /* To determine what functions are available we rely on one or both of:
  33. - the user's options.h generated by wolfSSL
  34. - the symbols detected by curl's configure
  35. Since they are markedly different from one another, and one or the other may
  36. not be available, we do some checking below to bring things in sync. */
  37. /* HAVE_ALPN is wolfSSL's build time symbol for enabling ALPN in options.h. */
  38. #ifndef HAVE_ALPN
  39. #ifdef HAVE_WOLFSSL_USEALPN
  40. #define HAVE_ALPN
  41. #endif
  42. #endif
  43. /* WOLFSSL_ALLOW_SSLV3 is wolfSSL's build time symbol for enabling SSLv3 in
  44. options.h, but is only seen in >= 3.6.6 since that's when they started
  45. disabling SSLv3 by default. */
  46. #ifndef WOLFSSL_ALLOW_SSLV3
  47. #if (LIBWOLFSSL_VERSION_HEX < 0x03006006) || \
  48. defined(HAVE_WOLFSSLV3_CLIENT_METHOD)
  49. #define WOLFSSL_ALLOW_SSLV3
  50. #endif
  51. #endif
  52. #include <limits.h>
  53. #include "urldata.h"
  54. #include "sendf.h"
  55. #include "inet_pton.h"
  56. #include "vtls.h"
  57. #include "keylog.h"
  58. #include "parsedate.h"
  59. #include "connect.h" /* for the connect timeout */
  60. #include "select.h"
  61. #include "strcase.h"
  62. #include "x509asn1.h"
  63. #include "curl_printf.h"
  64. #include "multiif.h"
  65. #include <wolfssl/openssl/ssl.h>
  66. #include <wolfssl/ssl.h>
  67. #include <wolfssl/error-ssl.h>
  68. #include "wolfssl.h"
  69. /* The last #include files should be: */
  70. #include "curl_memory.h"
  71. #include "memdebug.h"
  72. /* KEEP_PEER_CERT is a product of the presence of build time symbol
  73. OPENSSL_EXTRA without NO_CERTS, depending on the version. KEEP_PEER_CERT is
  74. in wolfSSL's settings.h, and the latter two are build time symbols in
  75. options.h. */
  76. #ifndef KEEP_PEER_CERT
  77. #if defined(HAVE_WOLFSSL_GET_PEER_CERTIFICATE) || \
  78. (defined(OPENSSL_EXTRA) && !defined(NO_CERTS))
  79. #define KEEP_PEER_CERT
  80. #endif
  81. #endif
  82. struct ssl_backend_data {
  83. SSL_CTX* ctx;
  84. SSL* handle;
  85. };
  86. static Curl_recv wolfssl_recv;
  87. static Curl_send wolfssl_send;
  88. #ifdef OPENSSL_EXTRA
  89. /*
  90. * Availability note:
  91. * The TLS 1.3 secret callback (wolfSSL_set_tls13_secret_cb) was added in
  92. * WolfSSL 4.4.0, but requires the -DHAVE_SECRET_CALLBACK build option. If that
  93. * option is not set, then TLS 1.3 will not be logged.
  94. * For TLS 1.2 and before, we use wolfSSL_get_keys().
  95. * SSL_get_client_random and wolfSSL_get_keys require OPENSSL_EXTRA
  96. * (--enable-opensslextra or --enable-all).
  97. */
  98. #if defined(HAVE_SECRET_CALLBACK) && defined(WOLFSSL_TLS13)
  99. static int
  100. wolfssl_tls13_secret_callback(SSL *ssl, int id, const unsigned char *secret,
  101. int secretSz, void *ctx)
  102. {
  103. const char *label;
  104. unsigned char client_random[SSL3_RANDOM_SIZE];
  105. (void)ctx;
  106. if(!ssl || !Curl_tls_keylog_enabled()) {
  107. return 0;
  108. }
  109. switch(id) {
  110. case CLIENT_EARLY_TRAFFIC_SECRET:
  111. label = "CLIENT_EARLY_TRAFFIC_SECRET";
  112. break;
  113. case CLIENT_HANDSHAKE_TRAFFIC_SECRET:
  114. label = "CLIENT_HANDSHAKE_TRAFFIC_SECRET";
  115. break;
  116. case SERVER_HANDSHAKE_TRAFFIC_SECRET:
  117. label = "SERVER_HANDSHAKE_TRAFFIC_SECRET";
  118. break;
  119. case CLIENT_TRAFFIC_SECRET:
  120. label = "CLIENT_TRAFFIC_SECRET_0";
  121. break;
  122. case SERVER_TRAFFIC_SECRET:
  123. label = "SERVER_TRAFFIC_SECRET_0";
  124. break;
  125. case EARLY_EXPORTER_SECRET:
  126. label = "EARLY_EXPORTER_SECRET";
  127. break;
  128. case EXPORTER_SECRET:
  129. label = "EXPORTER_SECRET";
  130. break;
  131. default:
  132. return 0;
  133. }
  134. if(SSL_get_client_random(ssl, client_random, SSL3_RANDOM_SIZE) == 0) {
  135. /* Should never happen as wolfSSL_KeepArrays() was called before. */
  136. return 0;
  137. }
  138. Curl_tls_keylog_write(label, client_random, secret, secretSz);
  139. return 0;
  140. }
  141. #endif /* defined(HAVE_SECRET_CALLBACK) && defined(WOLFSSL_TLS13) */
  142. static void
  143. wolfssl_log_tls12_secret(SSL *ssl)
  144. {
  145. unsigned char *ms, *sr, *cr;
  146. unsigned int msLen, srLen, crLen, i, x = 0;
  147. #if LIBWOLFSSL_VERSION_HEX >= 0x0300d000 /* >= 3.13.0 */
  148. /* wolfSSL_GetVersion is available since 3.13, we use it instead of
  149. * SSL_version since the latter relies on OPENSSL_ALL (--enable-opensslall or
  150. * --enable-all). Failing to perform this check could result in an unusable
  151. * key log line when TLS 1.3 is actually negotiated. */
  152. switch(wolfSSL_GetVersion(ssl)) {
  153. case WOLFSSL_SSLV3:
  154. case WOLFSSL_TLSV1:
  155. case WOLFSSL_TLSV1_1:
  156. case WOLFSSL_TLSV1_2:
  157. break;
  158. default:
  159. /* TLS 1.3 does not use this mechanism, the "master secret" returned below
  160. * is not directly usable. */
  161. return;
  162. }
  163. #endif
  164. if(SSL_get_keys(ssl, &ms, &msLen, &sr, &srLen, &cr, &crLen) != SSL_SUCCESS) {
  165. return;
  166. }
  167. /* Check for a missing master secret and skip logging. That can happen if
  168. * curl rejects the server certificate and aborts the handshake.
  169. */
  170. for(i = 0; i < msLen; i++) {
  171. x |= ms[i];
  172. }
  173. if(x == 0) {
  174. return;
  175. }
  176. Curl_tls_keylog_write("CLIENT_RANDOM", cr, ms, msLen);
  177. }
  178. #endif /* OPENSSL_EXTRA */
  179. static int do_file_type(const char *type)
  180. {
  181. if(!type || !type[0])
  182. return SSL_FILETYPE_PEM;
  183. if(strcasecompare(type, "PEM"))
  184. return SSL_FILETYPE_PEM;
  185. if(strcasecompare(type, "DER"))
  186. return SSL_FILETYPE_ASN1;
  187. return -1;
  188. }
  189. /*
  190. * This function loads all the client/CA certificates and CRLs. Setup the TLS
  191. * layer and do all necessary magic.
  192. */
  193. static CURLcode
  194. wolfssl_connect_step1(struct Curl_easy *data, struct connectdata *conn,
  195. int sockindex)
  196. {
  197. char *ciphers;
  198. struct ssl_connect_data *connssl = &conn->ssl[sockindex];
  199. struct ssl_backend_data *backend = connssl->backend;
  200. SSL_METHOD* req_method = NULL;
  201. curl_socket_t sockfd = conn->sock[sockindex];
  202. #ifdef HAVE_SNI
  203. bool sni = FALSE;
  204. #define use_sni(x) sni = (x)
  205. #else
  206. #define use_sni(x) Curl_nop_stmt
  207. #endif
  208. if(connssl->state == ssl_connection_complete)
  209. return CURLE_OK;
  210. if(SSL_CONN_CONFIG(version_max) != CURL_SSLVERSION_MAX_NONE) {
  211. failf(data, "wolfSSL does not support to set maximum SSL/TLS version");
  212. return CURLE_SSL_CONNECT_ERROR;
  213. }
  214. /* check to see if we've been told to use an explicit SSL/TLS version */
  215. switch(SSL_CONN_CONFIG(version)) {
  216. case CURL_SSLVERSION_DEFAULT:
  217. case CURL_SSLVERSION_TLSv1:
  218. #if LIBWOLFSSL_VERSION_HEX >= 0x03003000 /* >= 3.3.0 */
  219. /* minimum protocol version is set later after the CTX object is created */
  220. req_method = SSLv23_client_method();
  221. #else
  222. infof(data, "wolfSSL <3.3.0 cannot be configured to use TLS 1.0-1.2, "
  223. "TLS 1.0 is used exclusively\n");
  224. req_method = TLSv1_client_method();
  225. #endif
  226. use_sni(TRUE);
  227. break;
  228. case CURL_SSLVERSION_TLSv1_0:
  229. #if defined(WOLFSSL_ALLOW_TLSV10) && !defined(NO_OLD_TLS)
  230. req_method = TLSv1_client_method();
  231. use_sni(TRUE);
  232. #else
  233. failf(data, "wolfSSL does not support TLS 1.0");
  234. return CURLE_NOT_BUILT_IN;
  235. #endif
  236. break;
  237. case CURL_SSLVERSION_TLSv1_1:
  238. #ifndef NO_OLD_TLS
  239. req_method = TLSv1_1_client_method();
  240. use_sni(TRUE);
  241. #else
  242. failf(data, "wolfSSL does not support TLS 1.1");
  243. return CURLE_NOT_BUILT_IN;
  244. #endif
  245. break;
  246. case CURL_SSLVERSION_TLSv1_2:
  247. req_method = TLSv1_2_client_method();
  248. use_sni(TRUE);
  249. break;
  250. case CURL_SSLVERSION_TLSv1_3:
  251. #ifdef WOLFSSL_TLS13
  252. req_method = wolfTLSv1_3_client_method();
  253. use_sni(TRUE);
  254. break;
  255. #else
  256. failf(data, "wolfSSL: TLS 1.3 is not yet supported");
  257. return CURLE_SSL_CONNECT_ERROR;
  258. #endif
  259. case CURL_SSLVERSION_SSLv3:
  260. #ifdef WOLFSSL_ALLOW_SSLV3
  261. req_method = SSLv3_client_method();
  262. use_sni(FALSE);
  263. #else
  264. failf(data, "wolfSSL does not support SSLv3");
  265. return CURLE_NOT_BUILT_IN;
  266. #endif
  267. break;
  268. case CURL_SSLVERSION_SSLv2:
  269. failf(data, "wolfSSL does not support SSLv2");
  270. return CURLE_SSL_CONNECT_ERROR;
  271. default:
  272. failf(data, "Unrecognized parameter passed via CURLOPT_SSLVERSION");
  273. return CURLE_SSL_CONNECT_ERROR;
  274. }
  275. if(!req_method) {
  276. failf(data, "SSL: couldn't create a method!");
  277. return CURLE_OUT_OF_MEMORY;
  278. }
  279. if(backend->ctx)
  280. SSL_CTX_free(backend->ctx);
  281. backend->ctx = SSL_CTX_new(req_method);
  282. if(!backend->ctx) {
  283. failf(data, "SSL: couldn't create a context!");
  284. return CURLE_OUT_OF_MEMORY;
  285. }
  286. switch(SSL_CONN_CONFIG(version)) {
  287. case CURL_SSLVERSION_DEFAULT:
  288. case CURL_SSLVERSION_TLSv1:
  289. #if LIBWOLFSSL_VERSION_HEX > 0x03004006 /* > 3.4.6 */
  290. /* Versions 3.3.0 to 3.4.6 we know the minimum protocol version is
  291. * whatever minimum version of TLS was built in and at least TLS 1.0. For
  292. * later library versions that could change (eg TLS 1.0 built in but
  293. * defaults to TLS 1.1) so we have this short circuit evaluation to find
  294. * the minimum supported TLS version.
  295. */
  296. if((wolfSSL_CTX_SetMinVersion(backend->ctx, WOLFSSL_TLSV1) != 1) &&
  297. (wolfSSL_CTX_SetMinVersion(backend->ctx, WOLFSSL_TLSV1_1) != 1) &&
  298. (wolfSSL_CTX_SetMinVersion(backend->ctx, WOLFSSL_TLSV1_2) != 1)
  299. #ifdef WOLFSSL_TLS13
  300. && (wolfSSL_CTX_SetMinVersion(backend->ctx, WOLFSSL_TLSV1_3) != 1)
  301. #endif
  302. ) {
  303. failf(data, "SSL: couldn't set the minimum protocol version");
  304. return CURLE_SSL_CONNECT_ERROR;
  305. }
  306. #endif
  307. break;
  308. }
  309. ciphers = SSL_CONN_CONFIG(cipher_list);
  310. if(ciphers) {
  311. if(!SSL_CTX_set_cipher_list(backend->ctx, ciphers)) {
  312. failf(data, "failed setting cipher list: %s", ciphers);
  313. return CURLE_SSL_CIPHER;
  314. }
  315. infof(data, "Cipher selection: %s\n", ciphers);
  316. }
  317. #ifndef NO_FILESYSTEM
  318. /* load trusted cacert */
  319. if(SSL_CONN_CONFIG(CAfile)) {
  320. if(1 != SSL_CTX_load_verify_locations(backend->ctx,
  321. SSL_CONN_CONFIG(CAfile),
  322. SSL_CONN_CONFIG(CApath))) {
  323. if(SSL_CONN_CONFIG(verifypeer)) {
  324. /* Fail if we insist on successfully verifying the server. */
  325. failf(data, "error setting certificate verify locations:"
  326. " CAfile: %s CApath: %s",
  327. SSL_CONN_CONFIG(CAfile)?
  328. SSL_CONN_CONFIG(CAfile): "none",
  329. SSL_CONN_CONFIG(CApath)?
  330. SSL_CONN_CONFIG(CApath) : "none");
  331. return CURLE_SSL_CACERT_BADFILE;
  332. }
  333. else {
  334. /* Just continue with a warning if no strict certificate
  335. verification is required. */
  336. infof(data, "error setting certificate verify locations,"
  337. " continuing anyway:\n");
  338. }
  339. }
  340. else {
  341. /* Everything is fine. */
  342. infof(data, "successfully set certificate verify locations:\n");
  343. }
  344. infof(data, " CAfile: %s\n",
  345. SSL_CONN_CONFIG(CAfile) ? SSL_CONN_CONFIG(CAfile) : "none");
  346. infof(data, " CApath: %s\n",
  347. SSL_CONN_CONFIG(CApath) ? SSL_CONN_CONFIG(CApath) : "none");
  348. }
  349. /* Load the client certificate, and private key */
  350. if(SSL_SET_OPTION(primary.clientcert) && SSL_SET_OPTION(key)) {
  351. int file_type = do_file_type(SSL_SET_OPTION(cert_type));
  352. if(SSL_CTX_use_certificate_file(backend->ctx,
  353. SSL_SET_OPTION(primary.clientcert),
  354. file_type) != 1) {
  355. failf(data, "unable to use client certificate (no key or wrong pass"
  356. " phrase?)");
  357. return CURLE_SSL_CONNECT_ERROR;
  358. }
  359. file_type = do_file_type(SSL_SET_OPTION(key_type));
  360. if(SSL_CTX_use_PrivateKey_file(backend->ctx, SSL_SET_OPTION(key),
  361. file_type) != 1) {
  362. failf(data, "unable to set private key");
  363. return CURLE_SSL_CONNECT_ERROR;
  364. }
  365. }
  366. #endif /* !NO_FILESYSTEM */
  367. /* SSL always tries to verify the peer, this only says whether it should
  368. * fail to connect if the verification fails, or if it should continue
  369. * anyway. In the latter case the result of the verification is checked with
  370. * SSL_get_verify_result() below. */
  371. SSL_CTX_set_verify(backend->ctx,
  372. SSL_CONN_CONFIG(verifypeer)?SSL_VERIFY_PEER:
  373. SSL_VERIFY_NONE,
  374. NULL);
  375. #ifdef HAVE_SNI
  376. if(sni) {
  377. struct in_addr addr4;
  378. #ifdef ENABLE_IPV6
  379. struct in6_addr addr6;
  380. #endif
  381. #ifndef CURL_DISABLE_PROXY
  382. const char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :
  383. conn->host.name;
  384. #else
  385. const char * const hostname = conn->host.name;
  386. #endif
  387. size_t hostname_len = strlen(hostname);
  388. if((hostname_len < USHRT_MAX) &&
  389. (0 == Curl_inet_pton(AF_INET, hostname, &addr4)) &&
  390. #ifdef ENABLE_IPV6
  391. (0 == Curl_inet_pton(AF_INET6, hostname, &addr6)) &&
  392. #endif
  393. (wolfSSL_CTX_UseSNI(backend->ctx, WOLFSSL_SNI_HOST_NAME, hostname,
  394. (unsigned short)hostname_len) != 1)) {
  395. infof(data, "WARNING: failed to configure server name indication (SNI) "
  396. "TLS extension\n");
  397. }
  398. }
  399. #endif
  400. /* give application a chance to interfere with SSL set up. */
  401. if(data->set.ssl.fsslctx) {
  402. CURLcode result = (*data->set.ssl.fsslctx)(data, backend->ctx,
  403. data->set.ssl.fsslctxp);
  404. if(result) {
  405. failf(data, "error signaled by ssl ctx callback");
  406. return result;
  407. }
  408. }
  409. #ifdef NO_FILESYSTEM
  410. else if(SSL_CONN_CONFIG(verifypeer)) {
  411. failf(data, "SSL: Certificates can't be loaded because wolfSSL was built"
  412. " with \"no filesystem\". Either disable peer verification"
  413. " (insecure) or if you are building an application with libcurl you"
  414. " can load certificates via CURLOPT_SSL_CTX_FUNCTION.");
  415. return CURLE_SSL_CONNECT_ERROR;
  416. }
  417. #endif
  418. /* Let's make an SSL structure */
  419. if(backend->handle)
  420. SSL_free(backend->handle);
  421. backend->handle = SSL_new(backend->ctx);
  422. if(!backend->handle) {
  423. failf(data, "SSL: couldn't create a context (handle)!");
  424. return CURLE_OUT_OF_MEMORY;
  425. }
  426. #ifdef HAVE_ALPN
  427. if(conn->bits.tls_enable_alpn) {
  428. char protocols[128];
  429. *protocols = '\0';
  430. /* wolfSSL's ALPN protocol name list format is a comma separated string of
  431. protocols in descending order of preference, eg: "h2,http/1.1" */
  432. #ifdef USE_NGHTTP2
  433. if(data->set.httpversion >= CURL_HTTP_VERSION_2) {
  434. strcpy(protocols + strlen(protocols), NGHTTP2_PROTO_VERSION_ID ",");
  435. infof(data, "ALPN, offering %s\n", NGHTTP2_PROTO_VERSION_ID);
  436. }
  437. #endif
  438. strcpy(protocols + strlen(protocols), ALPN_HTTP_1_1);
  439. infof(data, "ALPN, offering %s\n", ALPN_HTTP_1_1);
  440. if(wolfSSL_UseALPN(backend->handle, protocols,
  441. (unsigned)strlen(protocols),
  442. WOLFSSL_ALPN_CONTINUE_ON_MISMATCH) != SSL_SUCCESS) {
  443. failf(data, "SSL: failed setting ALPN protocols");
  444. return CURLE_SSL_CONNECT_ERROR;
  445. }
  446. }
  447. #endif /* HAVE_ALPN */
  448. #ifdef OPENSSL_EXTRA
  449. if(Curl_tls_keylog_enabled()) {
  450. /* Ensure the Client Random is preserved. */
  451. wolfSSL_KeepArrays(backend->handle);
  452. #if defined(HAVE_SECRET_CALLBACK) && defined(WOLFSSL_TLS13)
  453. wolfSSL_set_tls13_secret_cb(backend->handle,
  454. wolfssl_tls13_secret_callback, NULL);
  455. #endif
  456. }
  457. #endif /* OPENSSL_EXTRA */
  458. #ifdef HAVE_SECURE_RENEGOTIATION
  459. if(wolfSSL_UseSecureRenegotiation(backend->handle) != SSL_SUCCESS) {
  460. failf(data, "SSL: failed setting secure renegotiation");
  461. return CURLE_SSL_CONNECT_ERROR;
  462. }
  463. #endif /* HAVE_SECURE_RENEGOTIATION */
  464. /* Check if there's a cached ID we can/should use here! */
  465. if(SSL_SET_OPTION(primary.sessionid)) {
  466. void *ssl_sessionid = NULL;
  467. Curl_ssl_sessionid_lock(data);
  468. if(!Curl_ssl_getsessionid(data, conn, &ssl_sessionid, NULL, sockindex)) {
  469. /* we got a session id, use it! */
  470. if(!SSL_set_session(backend->handle, ssl_sessionid)) {
  471. char error_buffer[WOLFSSL_MAX_ERROR_SZ];
  472. Curl_ssl_sessionid_unlock(data);
  473. failf(data, "SSL: SSL_set_session failed: %s",
  474. ERR_error_string(SSL_get_error(backend->handle, 0),
  475. error_buffer));
  476. return CURLE_SSL_CONNECT_ERROR;
  477. }
  478. /* Informational message */
  479. infof(data, "SSL re-using session ID\n");
  480. }
  481. Curl_ssl_sessionid_unlock(data);
  482. }
  483. /* pass the raw socket into the SSL layer */
  484. if(!SSL_set_fd(backend->handle, (int)sockfd)) {
  485. failf(data, "SSL: SSL_set_fd failed");
  486. return CURLE_SSL_CONNECT_ERROR;
  487. }
  488. connssl->connecting_state = ssl_connect_2;
  489. return CURLE_OK;
  490. }
  491. static CURLcode
  492. wolfssl_connect_step2(struct Curl_easy *data, struct connectdata *conn,
  493. int sockindex)
  494. {
  495. int ret = -1;
  496. struct ssl_connect_data *connssl = &conn->ssl[sockindex];
  497. struct ssl_backend_data *backend = connssl->backend;
  498. #ifndef CURL_DISABLE_PROXY
  499. const char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :
  500. conn->host.name;
  501. const char * const dispname = SSL_IS_PROXY() ?
  502. conn->http_proxy.host.dispname : conn->host.dispname;
  503. const char * const pinnedpubkey = SSL_IS_PROXY() ?
  504. data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] :
  505. data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG];
  506. #else
  507. const char * const hostname = conn->host.name;
  508. const char * const dispname = conn->host.dispname;
  509. const char * const pinnedpubkey =
  510. data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG];
  511. #endif
  512. conn->recv[sockindex] = wolfssl_recv;
  513. conn->send[sockindex] = wolfssl_send;
  514. /* Enable RFC2818 checks */
  515. if(SSL_CONN_CONFIG(verifyhost)) {
  516. ret = wolfSSL_check_domain_name(backend->handle, hostname);
  517. if(ret == SSL_FAILURE)
  518. return CURLE_OUT_OF_MEMORY;
  519. }
  520. ret = SSL_connect(backend->handle);
  521. #ifdef OPENSSL_EXTRA
  522. if(Curl_tls_keylog_enabled()) {
  523. /* If key logging is enabled, wait for the handshake to complete and then
  524. * proceed with logging secrets (for TLS 1.2 or older).
  525. *
  526. * During the handshake (ret==-1), wolfSSL_want_read() is true as it waits
  527. * for the server response. At that point the master secret is not yet
  528. * available, so we must not try to read it.
  529. * To log the secret on completion with a handshake failure, detect
  530. * completion via the observation that there is nothing to read or write.
  531. * Note that OpenSSL SSL_want_read() is always true here. If wolfSSL ever
  532. * changes, the worst case is that no key is logged on error.
  533. */
  534. if(ret == SSL_SUCCESS ||
  535. (!wolfSSL_want_read(backend->handle) &&
  536. !wolfSSL_want_write(backend->handle))) {
  537. wolfssl_log_tls12_secret(backend->handle);
  538. /* Client Random and master secrets are no longer needed, erase these.
  539. * Ignored while the handshake is still in progress. */
  540. wolfSSL_FreeArrays(backend->handle);
  541. }
  542. }
  543. #endif /* OPENSSL_EXTRA */
  544. if(ret != 1) {
  545. char error_buffer[WOLFSSL_MAX_ERROR_SZ];
  546. int detail = SSL_get_error(backend->handle, ret);
  547. if(SSL_ERROR_WANT_READ == detail) {
  548. connssl->connecting_state = ssl_connect_2_reading;
  549. return CURLE_OK;
  550. }
  551. else if(SSL_ERROR_WANT_WRITE == detail) {
  552. connssl->connecting_state = ssl_connect_2_writing;
  553. return CURLE_OK;
  554. }
  555. /* There is no easy way to override only the CN matching.
  556. * This will enable the override of both mismatching SubjectAltNames
  557. * as also mismatching CN fields */
  558. else if(DOMAIN_NAME_MISMATCH == detail) {
  559. #if 1
  560. failf(data, "\tsubject alt name(s) or common name do not match \"%s\"",
  561. dispname);
  562. return CURLE_PEER_FAILED_VERIFICATION;
  563. #else
  564. /* When the wolfssl_check_domain_name() is used and you desire to
  565. * continue on a DOMAIN_NAME_MISMATCH, i.e. 'conn->ssl_config.verifyhost
  566. * == 0', CyaSSL version 2.4.0 will fail with an INCOMPLETE_DATA
  567. * error. The only way to do this is currently to switch the
  568. * Wolfssl_check_domain_name() in and out based on the
  569. * 'conn->ssl_config.verifyhost' value. */
  570. if(SSL_CONN_CONFIG(verifyhost)) {
  571. failf(data,
  572. "\tsubject alt name(s) or common name do not match \"%s\"\n",
  573. dispname);
  574. return CURLE_PEER_FAILED_VERIFICATION;
  575. }
  576. else {
  577. infof(data,
  578. "\tsubject alt name(s) and/or common name do not match \"%s\"\n",
  579. dispname);
  580. return CURLE_OK;
  581. }
  582. #endif
  583. }
  584. #if LIBWOLFSSL_VERSION_HEX >= 0x02007000 /* 2.7.0 */
  585. else if(ASN_NO_SIGNER_E == detail) {
  586. if(SSL_CONN_CONFIG(verifypeer)) {
  587. failf(data, "\tCA signer not available for verification");
  588. return CURLE_SSL_CACERT_BADFILE;
  589. }
  590. else {
  591. /* Just continue with a warning if no strict certificate
  592. verification is required. */
  593. infof(data, "CA signer not available for verification, "
  594. "continuing anyway\n");
  595. }
  596. }
  597. #endif
  598. else {
  599. failf(data, "SSL_connect failed with error %d: %s", detail,
  600. ERR_error_string(detail, error_buffer));
  601. return CURLE_SSL_CONNECT_ERROR;
  602. }
  603. }
  604. if(pinnedpubkey) {
  605. #ifdef KEEP_PEER_CERT
  606. X509 *x509;
  607. const char *x509_der;
  608. int x509_der_len;
  609. struct Curl_X509certificate x509_parsed;
  610. struct Curl_asn1Element *pubkey;
  611. CURLcode result;
  612. x509 = SSL_get_peer_certificate(backend->handle);
  613. if(!x509) {
  614. failf(data, "SSL: failed retrieving server certificate");
  615. return CURLE_SSL_PINNEDPUBKEYNOTMATCH;
  616. }
  617. x509_der = (const char *)wolfSSL_X509_get_der(x509, &x509_der_len);
  618. if(!x509_der) {
  619. failf(data, "SSL: failed retrieving ASN.1 server certificate");
  620. return CURLE_SSL_PINNEDPUBKEYNOTMATCH;
  621. }
  622. memset(&x509_parsed, 0, sizeof(x509_parsed));
  623. if(Curl_parseX509(&x509_parsed, x509_der, x509_der + x509_der_len))
  624. return CURLE_SSL_PINNEDPUBKEYNOTMATCH;
  625. pubkey = &x509_parsed.subjectPublicKeyInfo;
  626. if(!pubkey->header || pubkey->end <= pubkey->header) {
  627. failf(data, "SSL: failed retrieving public key from server certificate");
  628. return CURLE_SSL_PINNEDPUBKEYNOTMATCH;
  629. }
  630. result = Curl_pin_peer_pubkey(data,
  631. pinnedpubkey,
  632. (const unsigned char *)pubkey->header,
  633. (size_t)(pubkey->end - pubkey->header));
  634. if(result) {
  635. failf(data, "SSL: public key does not match pinned public key!");
  636. return result;
  637. }
  638. #else
  639. failf(data, "Library lacks pinning support built-in");
  640. return CURLE_NOT_BUILT_IN;
  641. #endif
  642. }
  643. #ifdef HAVE_ALPN
  644. if(conn->bits.tls_enable_alpn) {
  645. int rc;
  646. char *protocol = NULL;
  647. unsigned short protocol_len = 0;
  648. rc = wolfSSL_ALPN_GetProtocol(backend->handle, &protocol, &protocol_len);
  649. if(rc == SSL_SUCCESS) {
  650. infof(data, "ALPN, server accepted to use %.*s\n", protocol_len,
  651. protocol);
  652. if(protocol_len == ALPN_HTTP_1_1_LENGTH &&
  653. !memcmp(protocol, ALPN_HTTP_1_1, ALPN_HTTP_1_1_LENGTH))
  654. conn->negnpn = CURL_HTTP_VERSION_1_1;
  655. #ifdef USE_NGHTTP2
  656. else if(data->set.httpversion >= CURL_HTTP_VERSION_2 &&
  657. protocol_len == NGHTTP2_PROTO_VERSION_ID_LEN &&
  658. !memcmp(protocol, NGHTTP2_PROTO_VERSION_ID,
  659. NGHTTP2_PROTO_VERSION_ID_LEN))
  660. conn->negnpn = CURL_HTTP_VERSION_2;
  661. #endif
  662. else
  663. infof(data, "ALPN, unrecognized protocol %.*s\n", protocol_len,
  664. protocol);
  665. Curl_multiuse_state(data, conn->negnpn == CURL_HTTP_VERSION_2 ?
  666. BUNDLE_MULTIPLEX : BUNDLE_NO_MULTIUSE);
  667. }
  668. else if(rc == SSL_ALPN_NOT_FOUND)
  669. infof(data, "ALPN, server did not agree to a protocol\n");
  670. else {
  671. failf(data, "ALPN, failure getting protocol, error %d", rc);
  672. return CURLE_SSL_CONNECT_ERROR;
  673. }
  674. }
  675. #endif /* HAVE_ALPN */
  676. connssl->connecting_state = ssl_connect_3;
  677. #if (LIBWOLFSSL_VERSION_HEX >= 0x03009010)
  678. infof(data, "SSL connection using %s / %s\n",
  679. wolfSSL_get_version(backend->handle),
  680. wolfSSL_get_cipher_name(backend->handle));
  681. #else
  682. infof(data, "SSL connected\n");
  683. #endif
  684. return CURLE_OK;
  685. }
  686. static CURLcode
  687. wolfssl_connect_step3(struct Curl_easy *data, struct connectdata *conn,
  688. int sockindex)
  689. {
  690. CURLcode result = CURLE_OK;
  691. struct ssl_connect_data *connssl = &conn->ssl[sockindex];
  692. struct ssl_backend_data *backend = connssl->backend;
  693. DEBUGASSERT(ssl_connect_3 == connssl->connecting_state);
  694. if(SSL_SET_OPTION(primary.sessionid)) {
  695. bool incache;
  696. SSL_SESSION *our_ssl_sessionid;
  697. void *old_ssl_sessionid = NULL;
  698. our_ssl_sessionid = SSL_get_session(backend->handle);
  699. Curl_ssl_sessionid_lock(data);
  700. incache = !(Curl_ssl_getsessionid(data, conn, &old_ssl_sessionid, NULL,
  701. sockindex));
  702. if(incache) {
  703. if(old_ssl_sessionid != our_ssl_sessionid) {
  704. infof(data, "old SSL session ID is stale, removing\n");
  705. Curl_ssl_delsessionid(data, old_ssl_sessionid);
  706. incache = FALSE;
  707. }
  708. }
  709. if(!incache) {
  710. result = Curl_ssl_addsessionid(data, conn, our_ssl_sessionid,
  711. 0 /* unknown size */, sockindex);
  712. if(result) {
  713. Curl_ssl_sessionid_unlock(data);
  714. failf(data, "failed to store ssl session");
  715. return result;
  716. }
  717. }
  718. Curl_ssl_sessionid_unlock(data);
  719. }
  720. connssl->connecting_state = ssl_connect_done;
  721. return result;
  722. }
  723. static ssize_t wolfssl_send(struct Curl_easy *data,
  724. int sockindex,
  725. const void *mem,
  726. size_t len,
  727. CURLcode *curlcode)
  728. {
  729. struct connectdata *conn = data->conn;
  730. struct ssl_connect_data *connssl = &conn->ssl[sockindex];
  731. struct ssl_backend_data *backend = connssl->backend;
  732. char error_buffer[WOLFSSL_MAX_ERROR_SZ];
  733. int memlen = (len > (size_t)INT_MAX) ? INT_MAX : (int)len;
  734. int rc = SSL_write(backend->handle, mem, memlen);
  735. if(rc < 0) {
  736. int err = SSL_get_error(backend->handle, rc);
  737. switch(err) {
  738. case SSL_ERROR_WANT_READ:
  739. case SSL_ERROR_WANT_WRITE:
  740. /* there's data pending, re-invoke SSL_write() */
  741. *curlcode = CURLE_AGAIN;
  742. return -1;
  743. default:
  744. failf(data, "SSL write: %s, errno %d",
  745. ERR_error_string(err, error_buffer),
  746. SOCKERRNO);
  747. *curlcode = CURLE_SEND_ERROR;
  748. return -1;
  749. }
  750. }
  751. return rc;
  752. }
  753. static void wolfssl_close(struct Curl_easy *data, struct connectdata *conn,
  754. int sockindex)
  755. {
  756. struct ssl_connect_data *connssl = &conn->ssl[sockindex];
  757. struct ssl_backend_data *backend = connssl->backend;
  758. (void) data;
  759. if(backend->handle) {
  760. (void)SSL_shutdown(backend->handle);
  761. SSL_free(backend->handle);
  762. backend->handle = NULL;
  763. }
  764. if(backend->ctx) {
  765. SSL_CTX_free(backend->ctx);
  766. backend->ctx = NULL;
  767. }
  768. }
  769. static ssize_t wolfssl_recv(struct Curl_easy *data,
  770. int num,
  771. char *buf,
  772. size_t buffersize,
  773. CURLcode *curlcode)
  774. {
  775. struct connectdata *conn = data->conn;
  776. struct ssl_connect_data *connssl = &conn->ssl[num];
  777. struct ssl_backend_data *backend = connssl->backend;
  778. char error_buffer[WOLFSSL_MAX_ERROR_SZ];
  779. int buffsize = (buffersize > (size_t)INT_MAX) ? INT_MAX : (int)buffersize;
  780. int nread = SSL_read(backend->handle, buf, buffsize);
  781. if(nread < 0) {
  782. int err = SSL_get_error(backend->handle, nread);
  783. switch(err) {
  784. case SSL_ERROR_ZERO_RETURN: /* no more data */
  785. break;
  786. case SSL_ERROR_WANT_READ:
  787. case SSL_ERROR_WANT_WRITE:
  788. /* there's data pending, re-invoke SSL_read() */
  789. *curlcode = CURLE_AGAIN;
  790. return -1;
  791. default:
  792. failf(data, "SSL read: %s, errno %d",
  793. ERR_error_string(err, error_buffer), SOCKERRNO);
  794. *curlcode = CURLE_RECV_ERROR;
  795. return -1;
  796. }
  797. }
  798. return nread;
  799. }
  800. static void wolfssl_session_free(void *ptr)
  801. {
  802. (void)ptr;
  803. /* wolfSSL reuses sessions on own, no free */
  804. }
  805. static size_t wolfssl_version(char *buffer, size_t size)
  806. {
  807. #if LIBWOLFSSL_VERSION_HEX >= 0x03006000
  808. return msnprintf(buffer, size, "wolfSSL/%s", wolfSSL_lib_version());
  809. #elif defined(WOLFSSL_VERSION)
  810. return msnprintf(buffer, size, "wolfSSL/%s", WOLFSSL_VERSION);
  811. #endif
  812. }
  813. static int wolfssl_init(void)
  814. {
  815. #ifdef OPENSSL_EXTRA
  816. Curl_tls_keylog_open();
  817. #endif
  818. return (wolfSSL_Init() == SSL_SUCCESS);
  819. }
  820. static void wolfssl_cleanup(void)
  821. {
  822. wolfSSL_Cleanup();
  823. #ifdef OPENSSL_EXTRA
  824. Curl_tls_keylog_close();
  825. #endif
  826. }
  827. static bool wolfssl_data_pending(const struct connectdata *conn,
  828. int connindex)
  829. {
  830. const struct ssl_connect_data *connssl = &conn->ssl[connindex];
  831. struct ssl_backend_data *backend = connssl->backend;
  832. if(backend->handle) /* SSL is in use */
  833. return (0 != SSL_pending(backend->handle)) ? TRUE : FALSE;
  834. else
  835. return FALSE;
  836. }
  837. /*
  838. * This function is called to shut down the SSL layer but keep the
  839. * socket open (CCC - Clear Command Channel)
  840. */
  841. static int wolfssl_shutdown(struct Curl_easy *data, struct connectdata *conn,
  842. int sockindex)
  843. {
  844. int retval = 0;
  845. struct ssl_connect_data *connssl = &conn->ssl[sockindex];
  846. struct ssl_backend_data *backend = connssl->backend;
  847. (void) data;
  848. if(backend->handle) {
  849. SSL_free(backend->handle);
  850. backend->handle = NULL;
  851. }
  852. return retval;
  853. }
  854. static CURLcode
  855. wolfssl_connect_common(struct Curl_easy *data,
  856. struct connectdata *conn,
  857. int sockindex,
  858. bool nonblocking,
  859. bool *done)
  860. {
  861. CURLcode result;
  862. struct ssl_connect_data *connssl = &conn->ssl[sockindex];
  863. curl_socket_t sockfd = conn->sock[sockindex];
  864. int what;
  865. /* check if the connection has already been established */
  866. if(ssl_connection_complete == connssl->state) {
  867. *done = TRUE;
  868. return CURLE_OK;
  869. }
  870. if(ssl_connect_1 == connssl->connecting_state) {
  871. /* Find out how much more time we're allowed */
  872. const timediff_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
  873. if(timeout_ms < 0) {
  874. /* no need to continue if time already is up */
  875. failf(data, "SSL connection timeout");
  876. return CURLE_OPERATION_TIMEDOUT;
  877. }
  878. result = wolfssl_connect_step1(data, conn, sockindex);
  879. if(result)
  880. return result;
  881. }
  882. while(ssl_connect_2 == connssl->connecting_state ||
  883. ssl_connect_2_reading == connssl->connecting_state ||
  884. ssl_connect_2_writing == connssl->connecting_state) {
  885. /* check allowed time left */
  886. const timediff_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
  887. if(timeout_ms < 0) {
  888. /* no need to continue if time already is up */
  889. failf(data, "SSL connection timeout");
  890. return CURLE_OPERATION_TIMEDOUT;
  891. }
  892. /* if ssl is expecting something, check if it's available. */
  893. if(connssl->connecting_state == ssl_connect_2_reading
  894. || connssl->connecting_state == ssl_connect_2_writing) {
  895. curl_socket_t writefd = ssl_connect_2_writing ==
  896. connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
  897. curl_socket_t readfd = ssl_connect_2_reading ==
  898. connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
  899. what = Curl_socket_check(readfd, CURL_SOCKET_BAD, writefd,
  900. nonblocking?0:timeout_ms);
  901. if(what < 0) {
  902. /* fatal error */
  903. failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO);
  904. return CURLE_SSL_CONNECT_ERROR;
  905. }
  906. else if(0 == what) {
  907. if(nonblocking) {
  908. *done = FALSE;
  909. return CURLE_OK;
  910. }
  911. else {
  912. /* timeout */
  913. failf(data, "SSL connection timeout");
  914. return CURLE_OPERATION_TIMEDOUT;
  915. }
  916. }
  917. /* socket is readable or writable */
  918. }
  919. /* Run transaction, and return to the caller if it failed or if
  920. * this connection is part of a multi handle and this loop would
  921. * execute again. This permits the owner of a multi handle to
  922. * abort a connection attempt before step2 has completed while
  923. * ensuring that a client using select() or epoll() will always
  924. * have a valid fdset to wait on.
  925. */
  926. result = wolfssl_connect_step2(data, conn, sockindex);
  927. if(result || (nonblocking &&
  928. (ssl_connect_2 == connssl->connecting_state ||
  929. ssl_connect_2_reading == connssl->connecting_state ||
  930. ssl_connect_2_writing == connssl->connecting_state)))
  931. return result;
  932. } /* repeat step2 until all transactions are done. */
  933. if(ssl_connect_3 == connssl->connecting_state) {
  934. result = wolfssl_connect_step3(data, conn, sockindex);
  935. if(result)
  936. return result;
  937. }
  938. if(ssl_connect_done == connssl->connecting_state) {
  939. connssl->state = ssl_connection_complete;
  940. conn->recv[sockindex] = wolfssl_recv;
  941. conn->send[sockindex] = wolfssl_send;
  942. *done = TRUE;
  943. }
  944. else
  945. *done = FALSE;
  946. /* Reset our connect state machine */
  947. connssl->connecting_state = ssl_connect_1;
  948. return CURLE_OK;
  949. }
  950. static CURLcode wolfssl_connect_nonblocking(struct Curl_easy *data,
  951. struct connectdata *conn,
  952. int sockindex, bool *done)
  953. {
  954. return wolfssl_connect_common(data, conn, sockindex, TRUE, done);
  955. }
  956. static CURLcode wolfssl_connect(struct Curl_easy *data,
  957. struct connectdata *conn, int sockindex)
  958. {
  959. CURLcode result;
  960. bool done = FALSE;
  961. result = wolfssl_connect_common(data, conn, sockindex, FALSE, &done);
  962. if(result)
  963. return result;
  964. DEBUGASSERT(done);
  965. return CURLE_OK;
  966. }
  967. static CURLcode wolfssl_random(struct Curl_easy *data,
  968. unsigned char *entropy, size_t length)
  969. {
  970. WC_RNG rng;
  971. (void)data;
  972. if(wc_InitRng(&rng))
  973. return CURLE_FAILED_INIT;
  974. if(length > UINT_MAX)
  975. return CURLE_FAILED_INIT;
  976. if(wc_RNG_GenerateBlock(&rng, entropy, (unsigned)length))
  977. return CURLE_FAILED_INIT;
  978. if(wc_FreeRng(&rng))
  979. return CURLE_FAILED_INIT;
  980. return CURLE_OK;
  981. }
  982. static CURLcode wolfssl_sha256sum(const unsigned char *tmp, /* input */
  983. size_t tmplen,
  984. unsigned char *sha256sum /* output */,
  985. size_t unused)
  986. {
  987. wc_Sha256 SHA256pw;
  988. (void)unused;
  989. wc_InitSha256(&SHA256pw);
  990. wc_Sha256Update(&SHA256pw, tmp, (word32)tmplen);
  991. wc_Sha256Final(&SHA256pw, sha256sum);
  992. return CURLE_OK;
  993. }
  994. static void *wolfssl_get_internals(struct ssl_connect_data *connssl,
  995. CURLINFO info UNUSED_PARAM)
  996. {
  997. struct ssl_backend_data *backend = connssl->backend;
  998. (void)info;
  999. return backend->handle;
  1000. }
  1001. const struct Curl_ssl Curl_ssl_wolfssl = {
  1002. { CURLSSLBACKEND_WOLFSSL, "WolfSSL" }, /* info */
  1003. #ifdef KEEP_PEER_CERT
  1004. SSLSUPP_PINNEDPUBKEY |
  1005. #endif
  1006. SSLSUPP_SSL_CTX,
  1007. sizeof(struct ssl_backend_data),
  1008. wolfssl_init, /* init */
  1009. wolfssl_cleanup, /* cleanup */
  1010. wolfssl_version, /* version */
  1011. Curl_none_check_cxn, /* check_cxn */
  1012. wolfssl_shutdown, /* shutdown */
  1013. wolfssl_data_pending, /* data_pending */
  1014. wolfssl_random, /* random */
  1015. Curl_none_cert_status_request, /* cert_status_request */
  1016. wolfssl_connect, /* connect */
  1017. wolfssl_connect_nonblocking, /* connect_nonblocking */
  1018. wolfssl_get_internals, /* get_internals */
  1019. wolfssl_close, /* close_one */
  1020. Curl_none_close_all, /* close_all */
  1021. wolfssl_session_free, /* session_free */
  1022. Curl_none_set_engine, /* set_engine */
  1023. Curl_none_set_engine_default, /* set_engine_default */
  1024. Curl_none_engines_list, /* engines_list */
  1025. Curl_none_false_start, /* false_start */
  1026. wolfssl_sha256sum /* sha256sum */
  1027. };
  1028. #endif