| 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/logging.h" | |
| 8 #include "base/values.h" | |
| 9 #include "chromeos/network/onc/onc_certificate_importer.h" | |
| 10 #include "chromeos/network/onc/onc_utils.h" | |
| 11 | |
| 12 namespace chromeos { | |
| 13 | |
| 14 CertificateHandler::CertificateHandler() { | |
| 15 } | |
| 16 | |
| 17 CertificateHandler::~CertificateHandler() { | |
| 18 } | |
| 19 | |
| 20 bool CertificateHandler::ImportCertificates( | |
| 21 const base::ListValue& certificates, | |
| 22 onc::ONCSource source, | |
| 23 net::CertificateList* onc_trusted_certificates) { | |
| 24 VLOG(2) << "ONC file has " << certificates.GetSize() << " certificates"; | |
| 25 | |
| 26 // Web trust is only granted to certificates imported by the user. | |
| 27 bool allow_trust_imports = source == onc::ONC_SOURCE_USER_IMPORT; | |
| 28 onc::CertificateImporter cert_importer(allow_trust_imports); | |
| 29 if (cert_importer.ParseAndStoreCertificates( | |
| 30 certificates, onc_trusted_certificates, NULL) != | |
| 31 onc::CertificateImporter::IMPORT_OK) { | |
| 32 LOG(ERROR) << "Cannot parse some of the certificates in the ONC from " | |
| 33 << onc::GetSourceAsString(source); | |
| 34 return false; | |
| 35 } | |
| 36 return true; | |
| 37 } | |
| 38 | |
| 39 } // namespace chromeos | |
| OLD | NEW |