Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: runtime/bin/secure_socket_macos.cc

Issue 1845273004: Allows adding trusted certs on iOS. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/bin/secure_socket_macos.h ('k') | sdk/lib/io/security_context.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #if !defined(DART_IO_DISABLED) && !defined(DART_IO_SECURE_SOCKET_DISABLED) 5 #if !defined(DART_IO_DISABLED) && !defined(DART_IO_SECURE_SOCKET_DISABLED)
6 6
7 #include "platform/globals.h" 7 #include "platform/globals.h"
8 #if defined(TARGET_OS_MACOS) && !TARGET_OS_IOS 8 #if defined(TARGET_OS_MACOS) && !TARGET_OS_IOS
9 9
10 #include "bin/secure_socket.h" 10 #include "bin/secure_socket.h"
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 result, 370 result,
371 kX509NativeFieldIndex, 371 kX509NativeFieldIndex,
372 reinterpret_cast<intptr_t>(certificate)); 372 reinterpret_cast<intptr_t>(certificate));
373 if (Dart_IsError(status)) { 373 if (Dart_IsError(status)) {
374 return status; 374 return status;
375 } 375 }
376 return result; 376 return result;
377 } 377 }
378 378
379 379
380 // Where the argument to the constructor is the handle for an object
381 // implementing List<int>, this class creates a scope in which the memory
382 // backing the list can be accessed.
383 //
384 // Do not make Dart_ API calls while in a ScopedMemBuffer.
385 // Do not call Dart_PropagateError while in a ScopedMemBuffer.
386 class ScopedMemBuffer {
387 public:
388 explicit ScopedMemBuffer(Dart_Handle object) {
389 if (!Dart_IsTypedData(object) && !Dart_IsList(object)) {
390 Dart_ThrowException(DartUtils::NewDartArgumentError(
391 "Argument is not a List<int>"));
392 }
393
394 uint8_t* bytes = NULL;
395 intptr_t bytes_len = 0;
396 bool is_typed_data = false;
397 if (Dart_IsTypedData(object)) {
398 is_typed_data = true;
399 Dart_TypedData_Type typ;
400 ThrowIfError(Dart_TypedDataAcquireData(
401 object,
402 &typ,
403 reinterpret_cast<void**>(&bytes),
404 &bytes_len));
405 } else {
406 ASSERT(Dart_IsList(object));
407 ThrowIfError(Dart_ListLength(object, &bytes_len));
408 bytes = Dart_ScopeAllocate(bytes_len);
409 ASSERT(bytes != NULL);
410 ThrowIfError(Dart_ListGetAsBytes(object, 0, bytes, bytes_len));
411 }
412
413 object_ = object;
414 bytes_ = bytes;
415 bytes_len_ = bytes_len;
416 is_typed_data_ = is_typed_data;
417 }
418
419 ~ScopedMemBuffer() {
420 if (is_typed_data_) {
421 ThrowIfError(Dart_TypedDataReleaseData(object_));
422 }
423 }
424
425 uint8_t* get() const { return bytes_; }
426 intptr_t length() const { return bytes_len_; }
427
428 private:
429 Dart_Handle object_;
430 uint8_t* bytes_;
431 intptr_t bytes_len_;
432 bool is_typed_data_;
433
434 DISALLOW_ALLOCATION();
435 DISALLOW_COPY_AND_ASSIGN(ScopedMemBuffer);
436 };
437
438
439 static const char* GetPasswordArgument(Dart_NativeArguments args, 380 static const char* GetPasswordArgument(Dart_NativeArguments args,
440 intptr_t index) { 381 intptr_t index) {
441 Dart_Handle password_object = 382 Dart_Handle password_object =
442 ThrowIfError(Dart_GetNativeArgument(args, index)); 383 ThrowIfError(Dart_GetNativeArgument(args, index));
443 const char* password = NULL; 384 const char* password = NULL;
444 if (Dart_IsString(password_object)) { 385 if (Dart_IsString(password_object)) {
445 ThrowIfError(Dart_StringToCString(password_object, &password)); 386 ThrowIfError(Dart_StringToCString(password_object, &password));
446 if (strlen(password) > PEM_BUFSIZE - 1) { 387 if (strlen(password) > PEM_BUFSIZE - 1) {
447 Dart_ThrowException(DartUtils::NewDartArgumentError( 388 Dart_ThrowException(DartUtils::NewDartArgumentError(
448 "Password length is greater than 1023 bytes.")); 389 "Password length is greater than 1023 bytes."));
(...skipping 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after
2019 return status; 1960 return status;
2020 } 1961 }
2021 1962
2022 } // namespace bin 1963 } // namespace bin
2023 } // namespace dart 1964 } // namespace dart
2024 1965
2025 #endif // defined(TARGET_OS_MACOS) && !TARGET_OS_IOS 1966 #endif // defined(TARGET_OS_MACOS) && !TARGET_OS_IOS
2026 1967
2027 #endif // !defined(DART_IO_DISABLED) && 1968 #endif // !defined(DART_IO_DISABLED) &&
2028 // !defined(DART_IO_SECURE_SOCKET_DISABLED) 1969 // !defined(DART_IO_SECURE_SOCKET_DISABLED)
OLDNEW
« no previous file with comments | « runtime/bin/secure_socket_macos.h ('k') | sdk/lib/io/security_context.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698