llappcorehttp.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. /**
  2. * @file llappcorehttp.cpp
  3. * @brief
  4. *
  5. * $LicenseInfo:firstyear=2012&license=viewergpl$
  6. *
  7. * Copyright (c) 2012, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #include "llviewerprecompiledheaders.h"
  33. #if 0 // Local SSL verification not implemented/used: we rely on libcurl
  34. # include "curl/curl.h"
  35. # include "openssl/x509_vfy.h"
  36. # include "openssl/ssl.h"
  37. # include "llsecapi.h"
  38. #endif
  39. #include "curl/curlver.h"
  40. #include "llappcorehttp.h"
  41. #include "lldir.h"
  42. #include "llappviewer.h"
  43. #include "llgridmanager.h" // For gIsInSecondLife
  44. #include "lltexturefetch.h"
  45. #include "llviewercontrol.h"
  46. // Here is where we begin to get our connection usage under control. This
  47. // establishes llcorehttp policy classes that, among other things, limit the
  48. // maximum number of connections to outside services. Each of the entries below
  49. // maps to a policy class and has a limit, sometimes configurable, of how many
  50. // connections can be open at a time.
  51. constexpr F64 MAX_THREAD_WAIT_TIME = 10.0;
  52. static const struct
  53. {
  54. U32 mDefault;
  55. U32 mMin;
  56. U32 mMax;
  57. U32 mRate;
  58. bool mPipelined;
  59. std::string mKey;
  60. const char* mUsage;
  61. } init_data[LLAppCoreHttp::AP_COUNT] =
  62. {
  63. { // AP_DEFAULT
  64. 8, 4, 8, 0, false,
  65. "",
  66. "other"
  67. },
  68. { // AP_TEXTURE
  69. 12, 2, 32, 0, true,
  70. "TextureFetchConcurrency",
  71. "texture fetch"
  72. },
  73. { // AP_MESH1
  74. 32, 1, 128, 0, false,
  75. "MeshMaxConcurrentRequests",
  76. "mesh fetch"
  77. },
  78. { // AP_MESH2
  79. 16, 1, 32, 0, true,
  80. "Mesh2MaxConcurrentRequests",
  81. "mesh2 fetch"
  82. },
  83. { // AP_LARGE_MESH
  84. 4, 1, 8, 0, false,
  85. "",
  86. "large mesh fetch"
  87. },
  88. { // AP_ASSETS
  89. 8, 2, 32, 0, true,
  90. "AssetFetchConcurrency",
  91. "asset fetch"
  92. },
  93. { // AP_UPLOADS
  94. 2, 1, 8, 0, false,
  95. "",
  96. "asset upload"
  97. },
  98. { // AP_LONG_POLL
  99. 32, 32, 32, 0, false,
  100. "",
  101. "long poll"
  102. },
  103. { // AP_INVENTORY
  104. 8, 1, 16, 0, true,
  105. "",
  106. "inventory"
  107. },
  108. { // AP_MATERIALS
  109. 2, 1, 8, 0, false,
  110. "MaterialFetchConcurrency",
  111. "material manager requests"
  112. },
  113. { // AP_AGENT
  114. 2, 1, 32, 0, false,
  115. "Agent",
  116. "Agent requests"
  117. }
  118. };
  119. constexpr S32 init_data_size = LL_ARRAY_SIZE(init_data);
  120. void setting_changed()
  121. {
  122. gAppViewerp->getAppCoreHttp().refreshSettings(false);
  123. }
  124. LLAppCoreHttp::HttpClass::HttpClass()
  125. : mPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID),
  126. mConnLimit(0U),
  127. mPipelined(false)
  128. {
  129. }
  130. LLAppCoreHttp::LLAppCoreHttp()
  131. : mRequest(NULL),
  132. mStopHandle(LLCORE_HTTP_HANDLE_INVALID),
  133. mStopRequested(0.0),
  134. mStopped(false),
  135. #if LL_CURL_BUG
  136. mPipelinedTempOff(false),
  137. mRestartPipelined(0.f),
  138. #endif
  139. mPipelined(true)
  140. {
  141. }
  142. LLAppCoreHttp::~LLAppCoreHttp()
  143. {
  144. delete mRequest;
  145. mRequest = NULL;
  146. }
  147. void LLAppCoreHttp::init()
  148. {
  149. LLCore::LLHttp::initialize();
  150. #if LIBCURL_VERSION_MAJOR > 7 || LIBCURL_VERSION_MINOR >= 54
  151. LLCore::LLHttp::gEnabledHTTP2 = gSavedSettings.getBool("EnableHTTP2");
  152. #else
  153. LLControlVariable* controlp = gSavedSettings.getControl("EnableHTTP2");
  154. if (controlp)
  155. {
  156. controlp->setHiddenFromUser(true);
  157. }
  158. #endif
  159. LLCore::HttpStatus status = LLCore::HttpRequest::createService();
  160. if (!status)
  161. {
  162. llerrs << "Failed to initialize HTTP services. Reason: "
  163. << status.toString() << llendl;
  164. }
  165. // Point to our certs or SSH/https: will fail on connect
  166. status =
  167. LLCore::HttpRequest::setStaticPolicyOption(LLCore::HttpRequest::PO_CA_FILE,
  168. LLCore::HttpRequest::GLOBAL_POLICY_ID,
  169. gDirUtil.getCRTFile(),
  170. NULL);
  171. if (!status)
  172. {
  173. llerrs << "Failed to set CA File for HTTP services. Reason: "
  174. << status.toString() << llendl;
  175. }
  176. // Establish HTTP Proxy if desired.
  177. status =
  178. LLCore::HttpRequest::setStaticPolicyOption(LLCore::HttpRequest::PO_LLPROXY,
  179. LLCore::HttpRequest::GLOBAL_POLICY_ID,
  180. 1, NULL);
  181. if (!status)
  182. {
  183. llwarns << "Failed to set HTTP proxy for HTTP services. Reason: "
  184. << status.toString() << llendl;
  185. }
  186. #if 0 // Not yet implemented/used (let libcurl do the job)
  187. // Set up SSL Verification call back.
  188. status =
  189. LLCore::HttpRequest::setStaticPolicyOption(LLCore::HttpRequest::PO_SSL_VERIFY_CALLBACK,
  190. LLCore::HttpRequest::GLOBAL_POLICY_ID,
  191. sslVerify, NULL);
  192. if (!status)
  193. {
  194. llwarns << "Failed to set SSL verification. Reason: "
  195. << status.toString() << llendl;
  196. }
  197. #endif
  198. // Tracing levels for library & libcurl (note that 2 & 3 are beyond spammy):
  199. // 0 - None
  200. // 1 - Basic start, stop simple transitions
  201. // 2 - libcurl CURLOPT_VERBOSE mode with brief lines
  202. // 3 - with partial data content
  203. long trace_level = gSavedSettings.getU32("HttpTraceLevel");
  204. status =
  205. LLCore::HttpRequest::setStaticPolicyOption(LLCore::HttpRequest::PO_TRACE,
  206. LLCore::HttpRequest::GLOBAL_POLICY_ID,
  207. trace_level, NULL);
  208. // Setup default policy and constrain if directed to
  209. mHttpClasses[AP_DEFAULT].mPolicy = LLCore::HttpRequest::DEFAULT_POLICY_ID;
  210. // Setup additional policies based on table and some special rules
  211. llassert(init_data_size == (S32)AP_COUNT);
  212. for (S32 i = 0, count = init_data_size; i < count; ++i)
  213. {
  214. const EAppPolicy app_policy = (EAppPolicy)i;
  215. if (app_policy == AP_DEFAULT)
  216. {
  217. // Pre-created
  218. continue;
  219. }
  220. mHttpClasses[app_policy].mPolicy =
  221. LLCore::HttpRequest::createPolicyClass();
  222. // We have ran out of available HTTP policies. Adjust
  223. // HTTP_POLICY_CLASS_LIMIT in llcorehttpinternal.h
  224. llassert(mHttpClasses[app_policy].mPolicy !=
  225. LLCore::HttpRequest::INVALID_POLICY_ID);
  226. if (!mHttpClasses[app_policy].mPolicy)
  227. {
  228. // Use default policy (but do not accidentally modify default)
  229. llwarns << "Failed to create HTTP policy class for "
  230. << init_data[i].mUsage << ". Using default policy."
  231. << llendl;
  232. mHttpClasses[app_policy].mPolicy =
  233. mHttpClasses[AP_DEFAULT].mPolicy;
  234. continue;
  235. }
  236. }
  237. // Need a request object to handle dynamic options before setting them
  238. mRequest = new LLCore::HttpRequest;
  239. // Apply initial settings
  240. refreshSettings(true);
  241. // Kick the thread
  242. status = LLCore::HttpRequest::startThread();
  243. if (!status)
  244. {
  245. llerrs << "Failed to start HTTP servicing thread. Reason: "
  246. << status.toString() << llendl;
  247. }
  248. // Signal for global pipelining preference from settings
  249. LLControlVariablePtr ctrl = gSavedSettings.getControl("HttpPipeliningSL");
  250. if (ctrl.notNull())
  251. {
  252. mPipelinedSignal =
  253. ctrl->getSignal()->connect(boost::bind(&setting_changed));
  254. }
  255. else
  256. {
  257. llwarns << "Unable to set signal on global setting: HttpPipeliningSL"
  258. << llendl;
  259. }
  260. ctrl = gSavedSettings.getControl("HttpPipeliningOS");
  261. if (ctrl.notNull())
  262. {
  263. mOSPipelinedSignal =
  264. ctrl->getSignal()->connect(boost::bind(&setting_changed));
  265. }
  266. else
  267. {
  268. llwarns << "Unable to set signal on global setting: HttpPipeliningOS"
  269. << llendl;
  270. }
  271. // Register signals for settings and state changes
  272. for (S32 i = 0, count = init_data_size; i < count; ++i)
  273. {
  274. const EAppPolicy app_policy = (EAppPolicy)i;
  275. std::string setting_name = init_data[i].mKey;
  276. if (!setting_name.empty() &&
  277. gSavedSettings.controlExists(setting_name.c_str()))
  278. {
  279. ctrl = gSavedSettings.getControl(setting_name.c_str());
  280. if (ctrl.notNull())
  281. {
  282. mHttpClasses[app_policy].mSettingsSignal =
  283. ctrl->getSignal()->connect(boost::bind(&setting_changed));
  284. }
  285. else
  286. {
  287. llwarns << "Unable to set signal on global setting: "
  288. << setting_name << llendl;
  289. }
  290. }
  291. }
  292. }
  293. namespace
  294. {
  295. // The NoOpDeletor is used when wrapping LLAppCoreHttp in a smart pointer
  296. // below for passage into the LLCore::Http libararies. When the smart
  297. // pointer is destroyed, no action will be taken since we do not in this
  298. // case want the entire LLAppCoreHttp object to be destroyed at the end of
  299. // the call.
  300. void NoOpDeletor(LLCore::HttpHandler*) {}
  301. }
  302. void LLAppCoreHttp::requestStop()
  303. {
  304. llassert_always(mRequest);
  305. mStopHandle =
  306. mRequest->requestStopThread(LLCore::HttpHandler::ptr_t(this,
  307. NoOpDeletor));
  308. if (mStopHandle != LLCORE_HTTP_HANDLE_INVALID)
  309. {
  310. mStopRequested = LLTimer::getTotalSeconds();
  311. }
  312. }
  313. void LLAppCoreHttp::cleanup()
  314. {
  315. if (mStopHandle == LLCORE_HTTP_HANDLE_INVALID)
  316. {
  317. // Should have been started already...
  318. requestStop();
  319. }
  320. if (mStopHandle == LLCORE_HTTP_HANDLE_INVALID)
  321. {
  322. llwarns << "Attempting to cleanup HTTP services without thread shutdown"
  323. << llendl;
  324. }
  325. else
  326. {
  327. while (!mStopped &&
  328. LLTimer::getTotalSeconds() < mStopRequested + MAX_THREAD_WAIT_TIME)
  329. {
  330. mRequest->update(200000);
  331. ms_sleep(50);
  332. }
  333. if (!mStopped)
  334. {
  335. llwarns << "Attempting to cleanup HTTP services with thread shutdown incomplete"
  336. << llendl;
  337. }
  338. }
  339. for (S32 i = 0, count = LL_ARRAY_SIZE(mHttpClasses); i < count; ++i)
  340. {
  341. mHttpClasses[i].mSettingsSignal.disconnect();
  342. }
  343. mPipelinedSignal.disconnect();
  344. mOSPipelinedSignal.disconnect();
  345. delete mRequest;
  346. mRequest = NULL;
  347. LLCore::HttpStatus status = LLCore::HttpRequest::destroyService();
  348. if (!status)
  349. {
  350. llwarns << "Failed to shutdown HTTP services, continuing. Reason: "
  351. << status.toString() << llendl;
  352. }
  353. }
  354. bool LLAppCoreHttp::isPipeliningOn()
  355. {
  356. static LLCachedControl<bool> sl_ok(gSavedSettings, "HttpPipeliningSL");
  357. static LLCachedControl<bool> os_ok(gSavedSettings, "HttpPipeliningOS");
  358. bool pipelined;
  359. if (gIsInSecondLife)
  360. {
  361. pipelined = sl_ok;
  362. }
  363. else
  364. {
  365. pipelined = os_ok;
  366. }
  367. #if LL_CURL_BUG
  368. return pipelined && !mPipelinedTempOff;
  369. #else
  370. return pipelined;
  371. #endif
  372. }
  373. void LLAppCoreHttp::refreshSettings(bool initial)
  374. {
  375. LLCore::HttpStatus status;
  376. // Global pipelining setting. Defaults to true (in ctor) if absent.
  377. bool pipeline_changed = false;
  378. bool pipelined = isPipeliningOn();
  379. if (pipelined != mPipelined)
  380. {
  381. mPipelined = pipelined;
  382. pipeline_changed = true;
  383. }
  384. if (initial || pipeline_changed)
  385. {
  386. llinfos << "HTTP pipelining is" << (initial ? " " : " now ")
  387. << (pipelined ? "enabled" : "disabled") << llendl;
  388. }
  389. for (S32 i = 0, count = init_data_size; i < count; ++i)
  390. {
  391. const EAppPolicy app_policy = (EAppPolicy)i;
  392. // Init-time only, can use the static setters here
  393. if (initial && init_data[i].mRate)
  394. {
  395. // Set any desired throttle
  396. status =
  397. LLCore::HttpRequest::setStaticPolicyOption(LLCore::HttpRequest::PO_THROTTLE_RATE,
  398. mHttpClasses[app_policy].mPolicy,
  399. init_data[i].mRate,
  400. NULL);
  401. if (!status)
  402. {
  403. llwarns << "Unable to set " << init_data[i].mUsage
  404. << " throttle rate. Reason: " << status.toString()
  405. << llendl;
  406. }
  407. }
  408. // Init or run-time settings. Must use the queued request API.
  409. // Pipelining changes
  410. if (initial || pipeline_changed)
  411. {
  412. bool to_pipeline = mPipelined && init_data[i].mPipelined;
  413. if (to_pipeline != mHttpClasses[app_policy].mPipelined)
  414. {
  415. // Pipeline election changing, set dynamic option via request
  416. long new_depth = to_pipeline ? PIPELINING_DEPTH : 0L;
  417. LLCore::HttpHandle handle =
  418. mRequest->setPolicyOption(LLCore::HttpRequest::PO_PIPELINING_DEPTH,
  419. mHttpClasses[app_policy].mPolicy,
  420. new_depth,
  421. LLCore::HttpHandler::ptr_t());
  422. if (handle == LLCORE_HTTP_HANDLE_INVALID)
  423. {
  424. status = mRequest->getStatus();
  425. llwarns << "Unable to set " << init_data[i].mUsage
  426. << " pipelining. Reason: " << status.toString()
  427. << llendl;
  428. }
  429. else
  430. {
  431. LL_DEBUGS("CoreHttp") << "Changed " << init_data[i].mUsage
  432. << " pipelining. New value: "
  433. << new_depth << LL_ENDL;
  434. mHttpClasses[app_policy].mPipelined = to_pipeline;
  435. }
  436. }
  437. }
  438. // Get target connection concurrency value
  439. U32 setting = init_data[i].mDefault;
  440. std::string setting_name = init_data[i].mKey;
  441. if (!setting_name.empty() &&
  442. gSavedSettings.controlExists(setting_name.c_str()))
  443. {
  444. U32 new_setting = gSavedSettings.getU32(setting_name.c_str());
  445. if (new_setting)
  446. {
  447. // Treat zero settings as an ask for default
  448. setting = llclamp(new_setting, init_data[i].mMin,
  449. init_data[i].mMax);
  450. }
  451. }
  452. if (initial || pipeline_changed ||
  453. setting != mHttpClasses[app_policy].mConnLimit)
  454. {
  455. // Set it and report. Strategies depend on pipelining:
  456. //
  457. // No Pipelining. llcorehttp manages connections itself based on
  458. // the PO_CONNECTION_LIMIT setting. Set both limits to the same
  459. // value for logical consistency. In the future, may hand over
  460. // connection management to libcurl after the connection cache has
  461. // been better vetted.
  462. //
  463. // Pipelining. libcurl is allowed to manage connections to a great
  464. // degree. Steady state will connection limit based on the per-host
  465. // setting. Transitions (region crossings, new avatars, etc) can
  466. // request additional outbound connections to other servers via 2x
  467. // total connection limit.
  468. U32 limit = mHttpClasses[app_policy].mPipelined ? 2 * setting
  469. : setting;
  470. LLCore::HttpHandle handle =
  471. mRequest->setPolicyOption(LLCore::HttpRequest::PO_CONNECTION_LIMIT,
  472. mHttpClasses[app_policy].mPolicy,
  473. (long)limit,
  474. LLCore::HttpHandler::ptr_t());
  475. if (handle == LLCORE_HTTP_HANDLE_INVALID)
  476. {
  477. status = mRequest->getStatus();
  478. llwarns << "Unable to set " << init_data[i].mUsage
  479. << " concurrency. Reason: " << status.toString()
  480. << llendl;
  481. }
  482. else
  483. {
  484. handle =
  485. mRequest->setPolicyOption(LLCore::HttpRequest::PO_PER_HOST_CONNECTION_LIMIT,
  486. mHttpClasses[app_policy].mPolicy,
  487. setting,
  488. LLCore::HttpHandler::ptr_t());
  489. if (handle == LLCORE_HTTP_HANDLE_INVALID)
  490. {
  491. status = mRequest->getStatus();
  492. llwarns << "Unable to set " << init_data[i].mUsage
  493. << " per-host concurrency. Reason: "
  494. << status.toString() << llendl;
  495. }
  496. else
  497. {
  498. LL_DEBUGS("CoreHttp") << "Changed " << init_data[i].mUsage
  499. << " concurrency. New value: "
  500. << setting << LL_ENDL;
  501. mHttpClasses[app_policy].mConnLimit = setting;
  502. if (initial && setting != init_data[i].mDefault)
  503. {
  504. llinfos << "Application settings overriding default "
  505. << init_data[i].mUsage
  506. << " concurrency. New value: " << setting
  507. << llendl;
  508. }
  509. }
  510. }
  511. }
  512. }
  513. }
  514. #if LL_CURL_BUG
  515. void LLAppCoreHttp::setPipelinedTempOff(bool turn_off)
  516. {
  517. if (turn_off)
  518. {
  519. mRestartPipelined = gFrameTimeSeconds + 30.f;
  520. llwarns << "Temporarily disabling HTTP pipelining" << llendl;
  521. }
  522. else
  523. {
  524. llinfos << "HTTP pipelining re-enabled" << llendl;
  525. mRestartPipelined = 0.f;
  526. }
  527. mPipelinedTempOff = turn_off;
  528. refreshSettings();
  529. }
  530. void LLAppCoreHttp::checkPipelinedTempOff()
  531. {
  532. if (mPipelinedTempOff && mRestartPipelined < gFrameTimeSeconds)
  533. {
  534. setPipelinedTempOff(false);
  535. }
  536. }
  537. #endif
  538. LLCore::HttpStatus LLAppCoreHttp::sslVerify(const std::string& url,
  539. const LLCore::HttpHandler::ptr_t& handler,
  540. void* userdata)
  541. {
  542. #if 0 // Not yet implemented
  543. if (gDisconnected)
  544. {
  545. return LLCore::HttpStatus(LLCore::HttpStatus::EXT_CURL_EASY,
  546. CURLE_OPERATION_TIMEDOUT);
  547. }
  548. X509_STORE_CTX* ctx = (X509_STORE_CTX*)userdata;
  549. LLCore::HttpStatus result;
  550. LLPointer<LLCertificateStore> store =
  551. gSecAPIHandler->getCertificateStore("");
  552. LLPointer<LLCertificateChain> chain =
  553. gSecAPIHandler->getCertificateChain(ctx);
  554. LLSD validation_params = LLSD::emptyMap();
  555. LLURI uri(url);
  556. validation_params[CERT_HOSTNAME] = uri.hostName();
  557. // *TODO: In the case of an exception while validating the cert, we need a
  558. // way to pass the offending(?) cert back out. *Rider*
  559. try
  560. {
  561. // Do not validate hostname. Let libcurl do it instead. That way, it
  562. // will handle redirects
  563. store->validate(VALIDATION_POLICY_SSL & ~VALIDATION_POLICY_HOSTNAME,
  564. chain, validation_params);
  565. }
  566. catch (LLCertValidationTrustException& cert_exception)
  567. {
  568. // This exception is is handled differently than the general cert
  569. // exceptions, as we allow the user to actually add the certificate
  570. // for trust. Therefore we pass back a different error code
  571. // NOTE: We are currently 'wired' to pass around CURL error codes. This
  572. // is somewhat clumsy, as we may run into errors that do not map
  573. // directly to curl error codes. Should be refactored with login
  574. // refactoring, perhaps.
  575. result = LLCore::HttpStatus(LLCore::HttpStatus::EXT_CURL_EASY,
  576. CURLE_SSL_CACERT);
  577. result.setMessage(cert_exception.getMessage());
  578. LLPointer<LLCertificate> cert = cert_exception.getCert();
  579. cert->ref(); // adding an extra ref here
  580. result.setErrorData(cert.get());
  581. // We should probably have a more generic way of passing information
  582. // back to the error handlers.
  583. }
  584. catch (LLCertException& cert_exception)
  585. {
  586. result = LLCore::HttpStatus(LLCore::HttpStatus::EXT_CURL_EASY,
  587. CURLE_SSL_PEER_CERTIFICATE);
  588. result.setMessage(cert_exception.getMessage());
  589. LLPointer<LLCertificate> cert = cert_exception.getCert();
  590. cert->ref(); // adding an extra ref here
  591. result.setErrorData(cert.get());
  592. }
  593. catch (...)
  594. {
  595. // Any other odd error, we just handle as a connect error.
  596. result = LLCore::HttpStatus(LLCore::HttpStatus::EXT_CURL_EASY,
  597. CURLE_SSL_CONNECT_ERROR);
  598. }
  599. #else
  600. LLCore::HttpStatus result(LLCore::HttpStatus::EXT_CURL_EASY, CURLE_OK);
  601. #endif
  602. return result;
  603. }