OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chromeos/network/certificate_handler.h" |
| 6 |
| 7 #include "base/values.h" |
| 8 #include "chromeos/network/onc/onc_certificate_importer.h" |
| 9 #include "chromeos/network/onc/onc_utils.h" |
| 10 |
| 11 namespace chromeos { |
| 12 |
| 13 CertificateHandler::CertificateHandler() { |
| 14 } |
| 15 |
| 16 CertificateHandler::~CertificateHandler() { |
| 17 } |
| 18 |
| 19 bool CertificateHandler::ImportCertificates( |
| 20 const base::ListValue& certificates, |
| 21 onc::ONCSource source, |
| 22 net::CertificateList* onc_trusted_certificates) { |
| 23 VLOG(2) << "ONC file has " << certificates.GetSize() << " certificates"; |
| 24 |
| 25 // Web trust is only granted to certificates imported by the user. |
| 26 bool allow_trust_imports = source == onc::ONC_SOURCE_USER_IMPORT; |
| 27 onc::CertificateImporter cert_importer(allow_trust_imports); |
| 28 if (cert_importer.ParseAndStoreCertificates( |
| 29 certificates, onc_trusted_certificates) != |
| 30 onc::CertificateImporter::IMPORT_OK) { |
| 31 LOG(ERROR) << "Cannot parse some of the certificates in the ONC from " |
| 32 << onc::GetSourceAsString(source); |
| 33 return false; |
| 34 } |
| 35 return true; |
| 36 } |
| 37 |
| 38 } // namespace chromeos |
OLD | NEW |