OLD | NEW |
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 #include "platform/globals.h" | 5 #include "platform/globals.h" |
6 #if defined(TARGET_OS_MACOS) | 6 #if defined(TARGET_OS_MACOS) |
7 | 7 |
8 #include "bin/secure_socket.h" | 8 #include "bin/secure_socket.h" |
9 #include "bin/secure_socket_macos.h" | 9 #include "bin/secure_socket_macos.h" |
10 | 10 |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 | 528 |
529 static OSStatus TryPEMImport(CFDataRef cfdata, | 529 static OSStatus TryPEMImport(CFDataRef cfdata, |
530 CFStringRef password, | 530 CFStringRef password, |
531 CFArrayRef* out_certs, | 531 CFArrayRef* out_certs, |
532 SecKeyRef* out_key) { | 532 SecKeyRef* out_key) { |
533 OSStatus status = noErr; | 533 OSStatus status = noErr; |
534 | 534 |
535 SecExternalFormat format = kSecFormatPEMSequence; | 535 SecExternalFormat format = kSecFormatPEMSequence; |
536 SecExternalItemType sitem_type = kSecItemTypeAggregate; | 536 SecExternalItemType sitem_type = kSecItemTypeAggregate; |
537 | 537 |
538 SecKeyImportExportParameters params; | 538 SecItemImportExportKeyParameters params; |
539 memset(¶ms, 0, sizeof(params)); | 539 memset(¶ms, 0, sizeof(params)); |
540 params.version = SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION; | 540 params.version = SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION; |
541 params.flags = kSecKeyNoAccessControl; | 541 params.flags = kSecKeyNoAccessControl; |
542 params.passphrase = password; | 542 params.passphrase = password; |
543 params.keyAttributes = CSSM_KEYATTR_EXTRACTABLE; | |
544 | 543 |
545 CFArrayRef items = NULL; | 544 CFArrayRef items = NULL; |
546 status = SecKeychainItemImport( | 545 status = SecItemImport( |
547 cfdata, NULL, &format, &sitem_type, 0, ¶ms, NULL, &items); | 546 cfdata, NULL, &format, &sitem_type, 0, ¶ms, NULL, &items); |
548 | 547 |
549 if (status != noErr) { | 548 if (status != noErr) { |
550 if (SSL_LOG_CERTS) { | 549 if (SSL_LOG_CERTS) { |
551 Log::Print("TrySecItemImport failed with: %ld, type = %d, format = %d\n", | 550 Log::Print("TrySecItemImport failed with: %ld, type = %d, format = %d\n", |
552 static_cast<intptr_t>(status), sitem_type, format); | 551 static_cast<intptr_t>(status), sitem_type, format); |
553 } | 552 } |
554 return status; | 553 return status; |
555 } | 554 } |
556 | 555 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 static OSStatus TryPKCS12Import(CFDataRef cfdata, | 622 static OSStatus TryPKCS12Import(CFDataRef cfdata, |
624 CFStringRef password, | 623 CFStringRef password, |
625 CFArrayRef* out_certs, | 624 CFArrayRef* out_certs, |
626 SecKeyRef* out_key, | 625 SecKeyRef* out_key, |
627 SecKeychainRef* out_keychain) { | 626 SecKeychainRef* out_keychain) { |
628 OSStatus status = noErr; | 627 OSStatus status = noErr; |
629 | 628 |
630 SecExternalFormat format = kSecFormatPKCS12; | 629 SecExternalFormat format = kSecFormatPKCS12; |
631 SecExternalItemType sitem_type = kSecItemTypeAggregate; | 630 SecExternalItemType sitem_type = kSecItemTypeAggregate; |
632 | 631 |
633 SecKeyImportExportParameters params; | 632 SecItemImportExportKeyParameters params; |
634 memset(¶ms, 0, sizeof(params)); | 633 memset(¶ms, 0, sizeof(params)); |
635 params.version = SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION; | 634 params.version = SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION; |
636 params.flags = kSecKeyNoAccessControl; | 635 params.flags = kSecKeyNoAccessControl; |
637 params.passphrase = password; | 636 params.passphrase = password; |
638 params.keyAttributes = CSSM_KEYATTR_EXTRACTABLE; | |
639 | 637 |
640 CFArrayRef items = NULL; | 638 CFArrayRef items = NULL; |
641 if (SSL_LOG_CERTS) { | 639 if (SSL_LOG_CERTS) { |
642 Log::Print("Trying PKCS12 import with: type = %d, format = %d\n", | 640 Log::Print("Trying PKCS12 import with: type = %d, format = %d\n", |
643 sitem_type, format); | 641 sitem_type, format); |
644 } | 642 } |
645 | 643 |
646 // The documentation for SecKeychainItemImport here: | 644 // The documentation for SecKeychainItemImport here: |
647 // | 645 // |
648 // https://developer.apple.com/library/mac/documentation/Security/Reference/ke
ychainservices/index.html | 646 // https://developer.apple.com/library/mac/documentation/Security/Reference/ke
ychainservices/index.html |
(...skipping 20 matching lines...) Expand all Loading... |
669 SecKeychainRef keychain = NULL; | 667 SecKeychainRef keychain = NULL; |
670 if (out_key != NULL) { | 668 if (out_key != NULL) { |
671 ASSERT(out_keychain != NULL); | 669 ASSERT(out_keychain != NULL); |
672 status = CreateKeychain(&keychain); | 670 status = CreateKeychain(&keychain); |
673 if (status != noErr) { | 671 if (status != noErr) { |
674 return status; | 672 return status; |
675 } | 673 } |
676 *out_keychain = keychain; | 674 *out_keychain = keychain; |
677 } | 675 } |
678 | 676 |
679 status = SecKeychainItemImport( | 677 status = SecItemImport( |
680 cfdata, NULL, &format, &sitem_type, 0, ¶ms, keychain, &items); | 678 cfdata, NULL, &format, &sitem_type, 0, ¶ms, keychain, &items); |
681 if (status != noErr) { | 679 if (status != noErr) { |
682 if (SSL_LOG_CERTS) { | 680 if (SSL_LOG_CERTS) { |
683 Log::Print("TrySecItemImport failed with: %ld, it = %d, format = %d\n", | 681 Log::Print("TrySecItemImport failed with: %ld, it = %d, format = %d\n", |
684 static_cast<intptr_t>(status), sitem_type, format); | 682 static_cast<intptr_t>(status), sitem_type, format); |
685 } | 683 } |
686 return status; | 684 return status; |
687 } | 685 } |
688 | 686 |
689 CFIndex items_length = (items == NULL) ? 0 : CFArrayGetCount(items); | 687 CFIndex items_length = (items == NULL) ? 0 : CFArrayGetCount(items); |
(...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2067 } | 2065 } |
2068 } | 2066 } |
2069 *bytes_processed = static_cast<intptr_t>(bytes); | 2067 *bytes_processed = static_cast<intptr_t>(bytes); |
2070 return status; | 2068 return status; |
2071 } | 2069 } |
2072 | 2070 |
2073 } // namespace bin | 2071 } // namespace bin |
2074 } // namespace dart | 2072 } // namespace dart |
2075 | 2073 |
2076 #endif // defined(TARGET_OS_MACOS) | 2074 #endif // defined(TARGET_OS_MACOS) |
OLD | NEW |