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 <cert.h> | 5 #include <cert.h> |
6 #include <cryptohi.h> | 6 #include <cryptohi.h> |
7 #include <keyhi.h> | 7 #include <keyhi.h> |
8 #include <secder.h> | 8 #include <secder.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 std::unique_ptr<net::CertificateList> matches, | 236 std::unique_ptr<net::CertificateList> matches, |
237 const std::string& error_message) { | 237 const std::string& error_message) { |
238 origin_task_runner_->PostTask( | 238 origin_task_runner_->PostTask( |
239 from, base::Bind(callback_, base::Passed(&matches), error_message)); | 239 from, base::Bind(callback_, base::Passed(&matches), error_message)); |
240 } | 240 } |
241 | 241 |
242 const std::string username_hash_; | 242 const std::string username_hash_; |
243 const bool use_system_key_slot_; | 243 const bool use_system_key_slot_; |
244 scoped_refptr<net::SSLCertRequestInfo> cert_request_info_; | 244 scoped_refptr<net::SSLCertRequestInfo> cert_request_info_; |
245 std::unique_ptr<net::ClientCertStore> cert_store_; | 245 std::unique_ptr<net::ClientCertStore> cert_store_; |
246 std::unique_ptr<net::CertificateList> certs_; | |
247 | 246 |
248 private: | 247 private: |
249 // Must be called on origin thread, therefore use CallBack(). | 248 // Must be called on origin thread, therefore use CallBack(). |
250 subtle::SelectCertificatesCallback callback_; | 249 subtle::SelectCertificatesCallback callback_; |
251 }; | 250 }; |
252 | 251 |
253 class GetCertificatesState : public NSSOperationState { | 252 class GetCertificatesState : public NSSOperationState { |
254 public: | 253 public: |
255 explicit GetCertificatesState(const GetCertificatesCallback& callback); | 254 explicit GetCertificatesState(const GetCertificatesCallback& callback); |
256 ~GetCertificatesState() override {} | 255 ~GetCertificatesState() override {} |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 .WithPriority(base::TaskPriority::BACKGROUND) | 542 .WithPriority(base::TaskPriority::BACKGROUND) |
544 .WithShutdownBehavior( | 543 .WithShutdownBehavior( |
545 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN), | 544 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN), |
546 base::Bind(&SignRSAOnWorkerThread, base::Passed(&state))); | 545 base::Bind(&SignRSAOnWorkerThread, base::Passed(&state))); |
547 } | 546 } |
548 | 547 |
549 // Called when ClientCertStoreChromeOS::GetClientCerts is done. Builds the list | 548 // Called when ClientCertStoreChromeOS::GetClientCerts is done. Builds the list |
550 // of net::CertificateList and calls back. Used by | 549 // of net::CertificateList and calls back. Used by |
551 // SelectCertificatesOnIOThread(). | 550 // SelectCertificatesOnIOThread(). |
552 void DidSelectCertificatesOnIOThread( | 551 void DidSelectCertificatesOnIOThread( |
553 std::unique_ptr<SelectCertificatesState> state) { | 552 std::unique_ptr<SelectCertificatesState> state, |
| 553 net::CertificateList certs) { |
554 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 554 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
555 state->CallBack(FROM_HERE, std::move(state->certs_), | 555 state->CallBack(FROM_HERE, |
| 556 base::MakeUnique<net::CertificateList>(std::move(certs)), |
556 std::string() /* no error */); | 557 std::string() /* no error */); |
557 } | 558 } |
558 | 559 |
559 // Continues selecting certificates on the IO thread. Used by | 560 // Continues selecting certificates on the IO thread. Used by |
560 // SelectClientCertificates(). | 561 // SelectClientCertificates(). |
561 void SelectCertificatesOnIOThread( | 562 void SelectCertificatesOnIOThread( |
562 std::unique_ptr<SelectCertificatesState> state) { | 563 std::unique_ptr<SelectCertificatesState> state) { |
563 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 564 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
564 state->cert_store_.reset(new ClientCertStoreChromeOS( | 565 state->cert_store_.reset(new ClientCertStoreChromeOS( |
565 nullptr, // no additional provider | 566 nullptr, // no additional provider |
566 base::MakeUnique<ClientCertFilterChromeOS>(state->use_system_key_slot_, | 567 base::MakeUnique<ClientCertFilterChromeOS>(state->use_system_key_slot_, |
567 state->username_hash_), | 568 state->username_hash_), |
568 ClientCertStoreChromeOS::PasswordDelegateFactory())); | 569 ClientCertStoreChromeOS::PasswordDelegateFactory())); |
569 | 570 |
570 state->certs_.reset(new net::CertificateList); | |
571 | |
572 SelectCertificatesState* state_ptr = state.get(); | 571 SelectCertificatesState* state_ptr = state.get(); |
573 state_ptr->cert_store_->GetClientCerts( | 572 state_ptr->cert_store_->GetClientCerts( |
574 *state_ptr->cert_request_info_, state_ptr->certs_.get(), | 573 *state_ptr->cert_request_info_, |
575 base::Bind(&DidSelectCertificatesOnIOThread, base::Passed(&state))); | 574 base::Bind(&DidSelectCertificatesOnIOThread, base::Passed(&state))); |
576 } | 575 } |
577 | 576 |
578 // Filters the obtained certificates on a worker thread. Used by | 577 // Filters the obtained certificates on a worker thread. Used by |
579 // DidGetCertificates(). | 578 // DidGetCertificates(). |
580 void FilterCertificatesOnWorkerThread( | 579 void FilterCertificatesOnWorkerThread( |
581 std::unique_ptr<GetCertificatesState> state) { | 580 std::unique_ptr<GetCertificatesState> state) { |
582 std::unique_ptr<net::CertificateList> client_certs(new net::CertificateList); | 581 std::unique_ptr<net::CertificateList> client_certs(new net::CertificateList); |
583 for (net::CertificateList::const_iterator it = state->certs_->begin(); | 582 for (net::CertificateList::const_iterator it = state->certs_->begin(); |
584 it != state->certs_->end(); | 583 it != state->certs_->end(); |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 NSSOperationState* state_ptr = state.get(); | 905 NSSOperationState* state_ptr = state.get(); |
907 GetCertDatabase(std::string() /* don't get any specific slot */, | 906 GetCertDatabase(std::string() /* don't get any specific slot */, |
908 base::Bind(&GetTokensWithDB, base::Passed(&state)), | 907 base::Bind(&GetTokensWithDB, base::Passed(&state)), |
909 browser_context, | 908 browser_context, |
910 state_ptr); | 909 state_ptr); |
911 } | 910 } |
912 | 911 |
913 } // namespace platform_keys | 912 } // namespace platform_keys |
914 | 913 |
915 } // namespace chromeos | 914 } // namespace chromeos |
OLD | NEW |