| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/platform_keys/platform_keys.h" | 5 #include "chrome/browser/chromeos/platform_keys/platform_keys.h" |
| 6 | 6 |
| 7 #include <cert.h> | 7 #include <cert.h> |
| 8 #include <cryptohi.h> | 8 #include <cryptohi.h> |
| 9 #include <keyhi.h> | 9 #include <keyhi.h> |
| 10 #include <secder.h> | 10 #include <secder.h> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/location.h" | 16 #include "base/location.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
| 20 #include "base/stl_util.h" | 20 #include "base/stl_util.h" |
| 21 #include "base/thread_task_runner_handle.h" | 21 #include "base/thread_task_runner_handle.h" |
| 22 #include "base/threading/worker_pool.h" | 22 #include "base/threading/worker_pool.h" |
| 23 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
| 24 #include "chrome/browser/browser_process_platform_part_chromeos.h" | 24 #include "chrome/browser/browser_process_platform_part_chromeos.h" |
| 25 #include "chrome/browser/chromeos/certificate_provider/certificate_provider.h" |
| 25 #include "chrome/browser/chromeos/net/client_cert_filter_chromeos.h" | 26 #include "chrome/browser/chromeos/net/client_cert_filter_chromeos.h" |
| 26 #include "chrome/browser/chromeos/net/client_cert_store_chromeos.h" | 27 #include "chrome/browser/chromeos/net/client_cert_store_chromeos.h" |
| 27 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 28 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 28 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 29 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 29 #include "chrome/browser/extensions/api/enterprise_platform_keys/enterprise_plat
form_keys_api.h" | 30 #include "chrome/browser/extensions/api/enterprise_platform_keys/enterprise_plat
form_keys_api.h" |
| 30 #include "chrome/browser/net/nss_context.h" | 31 #include "chrome/browser/net/nss_context.h" |
| 31 #include "chrome/browser/profiles/profile.h" | 32 #include "chrome/browser/profiles/profile.h" |
| 32 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 33 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
| 33 #include "content/public/browser/browser_context.h" | 34 #include "content/public/browser/browser_context.h" |
| 34 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
| 35 #include "crypto/nss_key_util.h" | 36 #include "crypto/nss_key_util.h" |
| 36 #include "crypto/scoped_nss_types.h" | 37 #include "crypto/scoped_nss_types.h" |
| 37 #include "net/base/crypto_module.h" | 38 #include "net/base/crypto_module.h" |
| 38 #include "net/base/net_errors.h" | 39 #include "net/base/net_errors.h" |
| 39 #include "net/cert/cert_database.h" | 40 #include "net/cert/cert_database.h" |
| 40 #include "net/cert/nss_cert_database.h" | 41 #include "net/cert/nss_cert_database.h" |
| 41 #include "net/cert/x509_certificate.h" | |
| 42 #include "net/cert/x509_util_nss.h" | 42 #include "net/cert/x509_util_nss.h" |
| 43 #include "net/ssl/ssl_cert_request_info.h" | 43 #include "net/ssl/ssl_cert_request_info.h" |
| 44 | 44 |
| 45 using content::BrowserContext; | 45 using content::BrowserContext; |
| 46 using content::BrowserThread; | 46 using content::BrowserThread; |
| 47 | 47 |
| 48 namespace { | 48 namespace { |
| 49 const char kErrorInternal[] = "Internal Error."; | 49 const char kErrorInternal[] = "Internal Error."; |
| 50 const char kErrorKeyNotFound[] = "Key not found."; | 50 const char kErrorKeyNotFound[] = "Key not found."; |
| 51 const char kErrorCertificateNotFound[] = "Certificate could not be found."; | 51 const char kErrorCertificateNotFound[] = "Certificate could not be found."; |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 scoped_ptr<SelectCertificatesState> state) { | 543 scoped_ptr<SelectCertificatesState> state) { |
| 544 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 544 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 545 state->CallBack(FROM_HERE, state->certs_.Pass(), | 545 state->CallBack(FROM_HERE, state->certs_.Pass(), |
| 546 std::string() /* no error */); | 546 std::string() /* no error */); |
| 547 } | 547 } |
| 548 | 548 |
| 549 // Continues selecting certificates on the IO thread. Used by | 549 // Continues selecting certificates on the IO thread. Used by |
| 550 // SelectClientCertificates(). | 550 // SelectClientCertificates(). |
| 551 void SelectCertificatesOnIOThread(scoped_ptr<SelectCertificatesState> state) { | 551 void SelectCertificatesOnIOThread(scoped_ptr<SelectCertificatesState> state) { |
| 552 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 552 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 553 state->cert_store_.reset(new chromeos::ClientCertStoreChromeOS( | 553 state->cert_store_.reset(new ClientCertStoreChromeOS( |
| 554 make_scoped_ptr(new chromeos::ClientCertFilterChromeOS( | 554 nullptr, // no additional provider |
| 555 state->use_system_key_slot_, state->username_hash_)), | 555 make_scoped_ptr(new ClientCertFilterChromeOS(state->use_system_key_slot_, |
| 556 chromeos::ClientCertStoreChromeOS::PasswordDelegateFactory())); | 556 state->username_hash_)), |
| 557 ClientCertStoreChromeOS::PasswordDelegateFactory())); |
| 557 | 558 |
| 558 state->certs_.reset(new net::CertificateList); | 559 state->certs_.reset(new net::CertificateList); |
| 559 | 560 |
| 560 SelectCertificatesState* state_ptr = state.get(); | 561 SelectCertificatesState* state_ptr = state.get(); |
| 561 state_ptr->cert_store_->GetClientCerts( | 562 state_ptr->cert_store_->GetClientCerts( |
| 562 *state_ptr->cert_request_info_, state_ptr->certs_.get(), | 563 *state_ptr->cert_request_info_, state_ptr->certs_.get(), |
| 563 base::Bind(&DidSelectCertificatesOnIOThread, base::Passed(&state))); | 564 base::Bind(&DidSelectCertificatesOnIOThread, base::Passed(&state))); |
| 564 } | 565 } |
| 565 | 566 |
| 566 // Filters the obtained certificates on a worker thread. Used by | 567 // Filters the obtained certificates on a worker thread. Used by |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 NSSOperationState* state_ptr = state.get(); | 894 NSSOperationState* state_ptr = state.get(); |
| 894 GetCertDatabase(std::string() /* don't get any specific slot */, | 895 GetCertDatabase(std::string() /* don't get any specific slot */, |
| 895 base::Bind(&GetTokensWithDB, base::Passed(&state)), | 896 base::Bind(&GetTokensWithDB, base::Passed(&state)), |
| 896 browser_context, | 897 browser_context, |
| 897 state_ptr); | 898 state_ptr); |
| 898 } | 899 } |
| 899 | 900 |
| 900 } // namespace platform_keys | 901 } // namespace platform_keys |
| 901 | 902 |
| 902 } // namespace chromeos | 903 } // namespace chromeos |
| OLD | NEW |