You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

554 lines
18 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright 2004 The WebRTC Project Authors. All rights reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #include <time.h>
  11. #if defined(WEBRTC_WIN)
  12. #include <windows.h>
  13. #include <winsock2.h>
  14. #include <ws2tcpip.h>
  15. #define SECURITY_WIN32
  16. #include <security.h>
  17. #endif
  18. #include <ctype.h> // for isspace
  19. #include <stdio.h> // for sprintf
  20. #include <utility> // for pair
  21. #include <vector>
  22. #include "absl/strings/match.h"
  23. #include "rtc_base/crypt_string.h" // for CryptString
  24. #include "rtc_base/http_common.h"
  25. #include "rtc_base/logging.h"
  26. #include "rtc_base/message_digest.h"
  27. #include "rtc_base/socket_address.h"
  28. #include "rtc_base/string_utils.h"
  29. #include "rtc_base/strings/string_builder.h"
  30. #include "rtc_base/third_party/base64/base64.h" // for Base64
  31. #include "rtc_base/zero_memory.h" // for ExplicitZeroMemory
  32. namespace rtc {
  33. namespace {
  34. #if defined(WEBRTC_WIN) && !defined(WINUWP)
  35. ///////////////////////////////////////////////////////////////////////////////
  36. // ConstantToLabel can be used to easily generate string names from constant
  37. // values. This can be useful for logging descriptive names of error messages.
  38. // Usage:
  39. // const ConstantToLabel LIBRARY_ERRORS[] = {
  40. // KLABEL(SOME_ERROR),
  41. // KLABEL(SOME_OTHER_ERROR),
  42. // ...
  43. // LASTLABEL
  44. // }
  45. //
  46. // int err = LibraryFunc();
  47. // LOG(LS_ERROR) << "LibraryFunc returned: "
  48. // << GetErrorName(err, LIBRARY_ERRORS);
  49. struct ConstantToLabel {
  50. int value;
  51. const char* label;
  52. };
  53. const char* LookupLabel(int value, const ConstantToLabel entries[]) {
  54. for (int i = 0; entries[i].label; ++i) {
  55. if (value == entries[i].value) {
  56. return entries[i].label;
  57. }
  58. }
  59. return 0;
  60. }
  61. std::string GetErrorName(int err, const ConstantToLabel* err_table) {
  62. if (err == 0)
  63. return "No error";
  64. if (err_table != 0) {
  65. if (const char* value = LookupLabel(err, err_table))
  66. return value;
  67. }
  68. char buffer[16];
  69. snprintf(buffer, sizeof(buffer), "0x%08x", err);
  70. return buffer;
  71. }
  72. #define KLABEL(x) \
  73. { x, #x }
  74. #define LASTLABEL \
  75. { 0, 0 }
  76. const ConstantToLabel SECURITY_ERRORS[] = {
  77. KLABEL(SEC_I_COMPLETE_AND_CONTINUE),
  78. KLABEL(SEC_I_COMPLETE_NEEDED),
  79. KLABEL(SEC_I_CONTEXT_EXPIRED),
  80. KLABEL(SEC_I_CONTINUE_NEEDED),
  81. KLABEL(SEC_I_INCOMPLETE_CREDENTIALS),
  82. KLABEL(SEC_I_RENEGOTIATE),
  83. KLABEL(SEC_E_CERT_EXPIRED),
  84. KLABEL(SEC_E_INCOMPLETE_MESSAGE),
  85. KLABEL(SEC_E_INSUFFICIENT_MEMORY),
  86. KLABEL(SEC_E_INTERNAL_ERROR),
  87. KLABEL(SEC_E_INVALID_HANDLE),
  88. KLABEL(SEC_E_INVALID_TOKEN),
  89. KLABEL(SEC_E_LOGON_DENIED),
  90. KLABEL(SEC_E_NO_AUTHENTICATING_AUTHORITY),
  91. KLABEL(SEC_E_NO_CREDENTIALS),
  92. KLABEL(SEC_E_NOT_OWNER),
  93. KLABEL(SEC_E_OK),
  94. KLABEL(SEC_E_SECPKG_NOT_FOUND),
  95. KLABEL(SEC_E_TARGET_UNKNOWN),
  96. KLABEL(SEC_E_UNKNOWN_CREDENTIALS),
  97. KLABEL(SEC_E_UNSUPPORTED_FUNCTION),
  98. KLABEL(SEC_E_UNTRUSTED_ROOT),
  99. KLABEL(SEC_E_WRONG_PRINCIPAL),
  100. LASTLABEL};
  101. #undef KLABEL
  102. #undef LASTLABEL
  103. #endif // defined(WEBRTC_WIN) && !defined(WINUWP)
  104. typedef std::pair<std::string, std::string> HttpAttribute;
  105. typedef std::vector<HttpAttribute> HttpAttributeList;
  106. inline bool IsEndOfAttributeName(size_t pos, size_t len, const char* data) {
  107. if (pos >= len)
  108. return true;
  109. if (isspace(static_cast<unsigned char>(data[pos])))
  110. return true;
  111. // The reason for this complexity is that some attributes may contain trailing
  112. // equal signs (like base64 tokens in Negotiate auth headers)
  113. if ((pos + 1 < len) && (data[pos] == '=') &&
  114. !isspace(static_cast<unsigned char>(data[pos + 1])) &&
  115. (data[pos + 1] != '=')) {
  116. return true;
  117. }
  118. return false;
  119. }
  120. void HttpParseAttributes(const char* data,
  121. size_t len,
  122. HttpAttributeList& attributes) {
  123. size_t pos = 0;
  124. while (true) {
  125. // Skip leading whitespace
  126. while ((pos < len) && isspace(static_cast<unsigned char>(data[pos]))) {
  127. ++pos;
  128. }
  129. // End of attributes?
  130. if (pos >= len)
  131. return;
  132. // Find end of attribute name
  133. size_t start = pos;
  134. while (!IsEndOfAttributeName(pos, len, data)) {
  135. ++pos;
  136. }
  137. HttpAttribute attribute;
  138. attribute.first.assign(data + start, data + pos);
  139. // Attribute has value?
  140. if ((pos < len) && (data[pos] == '=')) {
  141. ++pos; // Skip '='
  142. // Check if quoted value
  143. if ((pos < len) && (data[pos] == '"')) {
  144. while (++pos < len) {
  145. if (data[pos] == '"') {
  146. ++pos;
  147. break;
  148. }
  149. if ((data[pos] == '\\') && (pos + 1 < len))
  150. ++pos;
  151. attribute.second.append(1, data[pos]);
  152. }
  153. } else {
  154. while ((pos < len) && !isspace(static_cast<unsigned char>(data[pos])) &&
  155. (data[pos] != ',')) {
  156. attribute.second.append(1, data[pos++]);
  157. }
  158. }
  159. }
  160. attributes.push_back(attribute);
  161. if ((pos < len) && (data[pos] == ','))
  162. ++pos; // Skip ','
  163. }
  164. }
  165. bool HttpHasAttribute(const HttpAttributeList& attributes,
  166. const std::string& name,
  167. std::string* value) {
  168. for (HttpAttributeList::const_iterator it = attributes.begin();
  169. it != attributes.end(); ++it) {
  170. if (it->first == name) {
  171. if (value) {
  172. *value = it->second;
  173. }
  174. return true;
  175. }
  176. }
  177. return false;
  178. }
  179. bool HttpHasNthAttribute(HttpAttributeList& attributes,
  180. size_t index,
  181. std::string* name,
  182. std::string* value) {
  183. if (index >= attributes.size())
  184. return false;
  185. if (name)
  186. *name = attributes[index].first;
  187. if (value)
  188. *value = attributes[index].second;
  189. return true;
  190. }
  191. std::string quote(const std::string& str) {
  192. std::string result;
  193. result.push_back('"');
  194. for (size_t i = 0; i < str.size(); ++i) {
  195. if ((str[i] == '"') || (str[i] == '\\'))
  196. result.push_back('\\');
  197. result.push_back(str[i]);
  198. }
  199. result.push_back('"');
  200. return result;
  201. }
  202. #if defined(WEBRTC_WIN) && !defined(WINUWP)
  203. struct NegotiateAuthContext : public HttpAuthContext {
  204. CredHandle cred;
  205. CtxtHandle ctx;
  206. size_t steps;
  207. bool specified_credentials;
  208. NegotiateAuthContext(const std::string& auth, CredHandle c1, CtxtHandle c2)
  209. : HttpAuthContext(auth),
  210. cred(c1),
  211. ctx(c2),
  212. steps(0),
  213. specified_credentials(false) {}
  214. ~NegotiateAuthContext() override {
  215. DeleteSecurityContext(&ctx);
  216. FreeCredentialsHandle(&cred);
  217. }
  218. };
  219. #endif // defined(WEBRTC_WIN) && !defined(WINUWP)
  220. } // anonymous namespace
  221. HttpAuthResult HttpAuthenticate(const char* challenge,
  222. size_t len,
  223. const SocketAddress& server,
  224. const std::string& method,
  225. const std::string& uri,
  226. const std::string& username,
  227. const CryptString& password,
  228. HttpAuthContext*& context,
  229. std::string& response,
  230. std::string& auth_method) {
  231. HttpAttributeList args;
  232. HttpParseAttributes(challenge, len, args);
  233. HttpHasNthAttribute(args, 0, &auth_method, nullptr);
  234. if (context && (context->auth_method != auth_method))
  235. return HAR_IGNORE;
  236. // BASIC
  237. if (absl::EqualsIgnoreCase(auth_method, "basic")) {
  238. if (context)
  239. return HAR_CREDENTIALS; // Bad credentials
  240. if (username.empty())
  241. return HAR_CREDENTIALS; // Missing credentials
  242. context = new HttpAuthContext(auth_method);
  243. // TODO(bugs.webrtc.org/8905): Convert sensitive to a CryptString and also
  244. // return response as CryptString so contents get securely deleted
  245. // automatically.
  246. // std::string decoded = username + ":" + password;
  247. size_t len = username.size() + password.GetLength() + 2;
  248. char* sensitive = new char[len];
  249. size_t pos = strcpyn(sensitive, len, username.data(), username.size());
  250. pos += strcpyn(sensitive + pos, len - pos, ":");
  251. password.CopyTo(sensitive + pos, true);
  252. response = auth_method;
  253. response.append(" ");
  254. // TODO: create a sensitive-source version of Base64::encode
  255. response.append(Base64::Encode(sensitive));
  256. ExplicitZeroMemory(sensitive, len);
  257. delete[] sensitive;
  258. return HAR_RESPONSE;
  259. }
  260. // DIGEST
  261. if (absl::EqualsIgnoreCase(auth_method, "digest")) {
  262. if (context)
  263. return HAR_CREDENTIALS; // Bad credentials
  264. if (username.empty())
  265. return HAR_CREDENTIALS; // Missing credentials
  266. context = new HttpAuthContext(auth_method);
  267. std::string cnonce, ncount;
  268. char buffer[256];
  269. sprintf(buffer, "%d", static_cast<int>(time(0)));
  270. cnonce = MD5(buffer);
  271. ncount = "00000001";
  272. std::string realm, nonce, qop, opaque;
  273. HttpHasAttribute(args, "realm", &realm);
  274. HttpHasAttribute(args, "nonce", &nonce);
  275. bool has_qop = HttpHasAttribute(args, "qop", &qop);
  276. bool has_opaque = HttpHasAttribute(args, "opaque", &opaque);
  277. // TODO(bugs.webrtc.org/8905): Convert sensitive to a CryptString and also
  278. // return response as CryptString so contents get securely deleted
  279. // automatically.
  280. // std::string A1 = username + ":" + realm + ":" + password;
  281. size_t len = username.size() + realm.size() + password.GetLength() + 3;
  282. char* sensitive = new char[len]; // A1
  283. size_t pos = strcpyn(sensitive, len, username.data(), username.size());
  284. pos += strcpyn(sensitive + pos, len - pos, ":");
  285. pos += strcpyn(sensitive + pos, len - pos, realm.c_str());
  286. pos += strcpyn(sensitive + pos, len - pos, ":");
  287. password.CopyTo(sensitive + pos, true);
  288. std::string A2 = method + ":" + uri;
  289. std::string middle;
  290. if (has_qop) {
  291. qop = "auth";
  292. middle = nonce + ":" + ncount + ":" + cnonce + ":" + qop;
  293. } else {
  294. middle = nonce;
  295. }
  296. std::string HA1 = MD5(sensitive);
  297. ExplicitZeroMemory(sensitive, len);
  298. delete[] sensitive;
  299. std::string HA2 = MD5(A2);
  300. std::string dig_response = MD5(HA1 + ":" + middle + ":" + HA2);
  301. rtc::StringBuilder ss;
  302. ss << auth_method;
  303. ss << " username=" << quote(username);
  304. ss << ", realm=" << quote(realm);
  305. ss << ", nonce=" << quote(nonce);
  306. ss << ", uri=" << quote(uri);
  307. if (has_qop) {
  308. ss << ", qop=" << qop;
  309. ss << ", nc=" << ncount;
  310. ss << ", cnonce=" << quote(cnonce);
  311. }
  312. ss << ", response=\"" << dig_response << "\"";
  313. if (has_opaque) {
  314. ss << ", opaque=" << quote(opaque);
  315. }
  316. response = ss.str();
  317. return HAR_RESPONSE;
  318. }
  319. #if defined(WEBRTC_WIN) && !defined(WINUWP)
  320. #if 1
  321. bool want_negotiate = absl::EqualsIgnoreCase(auth_method, "negotiate");
  322. bool want_ntlm = absl::EqualsIgnoreCase(auth_method, "ntlm");
  323. // SPNEGO & NTLM
  324. if (want_negotiate || want_ntlm) {
  325. const size_t MAX_MESSAGE = 12000, MAX_SPN = 256;
  326. char out_buf[MAX_MESSAGE], spn[MAX_SPN];
  327. #if 0 // Requires funky windows versions
  328. DWORD len = MAX_SPN;
  329. if (DsMakeSpn("HTTP", server.HostAsURIString().c_str(), nullptr,
  330. server.port(),
  331. 0, &len, spn) != ERROR_SUCCESS) {
  332. RTC_LOG_F(WARNING) << "(Negotiate) - DsMakeSpn failed";
  333. return HAR_IGNORE;
  334. }
  335. #else
  336. snprintf(spn, MAX_SPN, "HTTP/%s", server.ToString().c_str());
  337. #endif
  338. SecBuffer out_sec;
  339. out_sec.pvBuffer = out_buf;
  340. out_sec.cbBuffer = sizeof(out_buf);
  341. out_sec.BufferType = SECBUFFER_TOKEN;
  342. SecBufferDesc out_buf_desc;
  343. out_buf_desc.ulVersion = 0;
  344. out_buf_desc.cBuffers = 1;
  345. out_buf_desc.pBuffers = &out_sec;
  346. const ULONG NEG_FLAGS_DEFAULT =
  347. // ISC_REQ_ALLOCATE_MEMORY
  348. ISC_REQ_CONFIDENTIALITY
  349. //| ISC_REQ_EXTENDED_ERROR
  350. //| ISC_REQ_INTEGRITY
  351. | ISC_REQ_REPLAY_DETECT | ISC_REQ_SEQUENCE_DETECT
  352. //| ISC_REQ_STREAM
  353. //| ISC_REQ_USE_SUPPLIED_CREDS
  354. ;
  355. ::TimeStamp lifetime;
  356. SECURITY_STATUS ret = S_OK;
  357. ULONG ret_flags = 0, flags = NEG_FLAGS_DEFAULT;
  358. bool specify_credentials = !username.empty();
  359. size_t steps = 0;
  360. // uint32_t now = Time();
  361. NegotiateAuthContext* neg = static_cast<NegotiateAuthContext*>(context);
  362. if (neg) {
  363. const size_t max_steps = 10;
  364. if (++neg->steps >= max_steps) {
  365. RTC_LOG(WARNING) << "AsyncHttpsProxySocket::Authenticate(Negotiate) "
  366. "too many retries";
  367. return HAR_ERROR;
  368. }
  369. steps = neg->steps;
  370. std::string challenge, decoded_challenge;
  371. if (HttpHasNthAttribute(args, 1, &challenge, nullptr) &&
  372. Base64::Decode(challenge, Base64::DO_STRICT, &decoded_challenge,
  373. nullptr)) {
  374. SecBuffer in_sec;
  375. in_sec.pvBuffer = const_cast<char*>(decoded_challenge.data());
  376. in_sec.cbBuffer = static_cast<unsigned long>(decoded_challenge.size());
  377. in_sec.BufferType = SECBUFFER_TOKEN;
  378. SecBufferDesc in_buf_desc;
  379. in_buf_desc.ulVersion = 0;
  380. in_buf_desc.cBuffers = 1;
  381. in_buf_desc.pBuffers = &in_sec;
  382. ret = InitializeSecurityContextA(
  383. &neg->cred, &neg->ctx, spn, flags, 0, SECURITY_NATIVE_DREP,
  384. &in_buf_desc, 0, &neg->ctx, &out_buf_desc, &ret_flags, &lifetime);
  385. if (FAILED(ret)) {
  386. RTC_LOG(LS_ERROR) << "InitializeSecurityContext returned: "
  387. << GetErrorName(ret, SECURITY_ERRORS);
  388. return HAR_ERROR;
  389. }
  390. } else if (neg->specified_credentials) {
  391. // Try again with default credentials
  392. specify_credentials = false;
  393. delete context;
  394. context = neg = 0;
  395. } else {
  396. return HAR_CREDENTIALS;
  397. }
  398. }
  399. if (!neg) {
  400. unsigned char userbuf[256], passbuf[256], domainbuf[16];
  401. SEC_WINNT_AUTH_IDENTITY_A auth_id, *pauth_id = 0;
  402. if (specify_credentials) {
  403. memset(&auth_id, 0, sizeof(auth_id));
  404. size_t len = password.GetLength() + 1;
  405. char* sensitive = new char[len];
  406. password.CopyTo(sensitive, true);
  407. std::string::size_type pos = username.find('\\');
  408. if (pos == std::string::npos) {
  409. auth_id.UserLength = static_cast<unsigned long>(
  410. std::min(sizeof(userbuf) - 1, username.size()));
  411. memcpy(userbuf, username.c_str(), auth_id.UserLength);
  412. userbuf[auth_id.UserLength] = 0;
  413. auth_id.DomainLength = 0;
  414. domainbuf[auth_id.DomainLength] = 0;
  415. auth_id.PasswordLength = static_cast<unsigned long>(
  416. std::min(sizeof(passbuf) - 1, password.GetLength()));
  417. memcpy(passbuf, sensitive, auth_id.PasswordLength);
  418. passbuf[auth_id.PasswordLength] = 0;
  419. } else {
  420. auth_id.UserLength = static_cast<unsigned long>(
  421. std::min(sizeof(userbuf) - 1, username.size() - pos - 1));
  422. memcpy(userbuf, username.c_str() + pos + 1, auth_id.UserLength);
  423. userbuf[auth_id.UserLength] = 0;
  424. auth_id.DomainLength =
  425. static_cast<unsigned long>(std::min(sizeof(domainbuf) - 1, pos));
  426. memcpy(domainbuf, username.c_str(), auth_id.DomainLength);
  427. domainbuf[auth_id.DomainLength] = 0;
  428. auth_id.PasswordLength = static_cast<unsigned long>(
  429. std::min(sizeof(passbuf) - 1, password.GetLength()));
  430. memcpy(passbuf, sensitive, auth_id.PasswordLength);
  431. passbuf[auth_id.PasswordLength] = 0;
  432. }
  433. ExplicitZeroMemory(sensitive, len);
  434. delete[] sensitive;
  435. auth_id.User = userbuf;
  436. auth_id.Domain = domainbuf;
  437. auth_id.Password = passbuf;
  438. auth_id.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI;
  439. pauth_id = &auth_id;
  440. RTC_LOG(LS_VERBOSE)
  441. << "Negotiate protocol: Using specified credentials";
  442. } else {
  443. RTC_LOG(LS_VERBOSE) << "Negotiate protocol: Using default credentials";
  444. }
  445. CredHandle cred;
  446. ret = AcquireCredentialsHandleA(
  447. 0, const_cast<char*>(want_negotiate ? NEGOSSP_NAME_A : NTLMSP_NAME_A),
  448. SECPKG_CRED_OUTBOUND, 0, pauth_id, 0, 0, &cred, &lifetime);
  449. if (ret != SEC_E_OK) {
  450. RTC_LOG(LS_ERROR) << "AcquireCredentialsHandle error: "
  451. << GetErrorName(ret, SECURITY_ERRORS);
  452. return HAR_IGNORE;
  453. }
  454. // CSecBufferBundle<5, CSecBufferBase::FreeSSPI> sb_out;
  455. CtxtHandle ctx;
  456. ret = InitializeSecurityContextA(&cred, 0, spn, flags, 0,
  457. SECURITY_NATIVE_DREP, 0, 0, &ctx,
  458. &out_buf_desc, &ret_flags, &lifetime);
  459. if (FAILED(ret)) {
  460. RTC_LOG(LS_ERROR) << "InitializeSecurityContext returned: "
  461. << GetErrorName(ret, SECURITY_ERRORS);
  462. FreeCredentialsHandle(&cred);
  463. return HAR_IGNORE;
  464. }
  465. RTC_DCHECK(!context);
  466. context = neg = new NegotiateAuthContext(auth_method, cred, ctx);
  467. neg->specified_credentials = specify_credentials;
  468. neg->steps = steps;
  469. }
  470. if ((ret == SEC_I_COMPLETE_NEEDED) ||
  471. (ret == SEC_I_COMPLETE_AND_CONTINUE)) {
  472. ret = CompleteAuthToken(&neg->ctx, &out_buf_desc);
  473. RTC_LOG(LS_VERBOSE) << "CompleteAuthToken returned: "
  474. << GetErrorName(ret, SECURITY_ERRORS);
  475. if (FAILED(ret)) {
  476. return HAR_ERROR;
  477. }
  478. }
  479. std::string decoded(out_buf, out_buf + out_sec.cbBuffer);
  480. response = auth_method;
  481. response.append(" ");
  482. response.append(Base64::Encode(decoded));
  483. return HAR_RESPONSE;
  484. }
  485. #endif
  486. #endif // defined(WEBRTC_WIN) && !defined(WINUWP)
  487. return HAR_IGNORE;
  488. }
  489. //////////////////////////////////////////////////////////////////////
  490. } // namespace rtc