Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(522)

Side by Side Diff: net/test/cert_test_util_nss.cc

Issue 394013005: Remove NSSCertDatabase from ClientCertStoreChromeOS unittest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« net/test/cert_test_util.h ('K') | « net/test/cert_test_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 "net/test/cert_test_util.h"
6
7 #include "base/file_util.h"
8 #include "base/files/file_path.h"
9 #include "base/path_service.h"
10
11 namespace net {
12
13 scoped_ptr<crypto::RSAPrivateKey> ImportSensitiveKeyFromFile(
14 const base::FilePath& dir,
15 const std::string& key_filename,
16 PK11SlotInfo* slot) {
17 base::FilePath key_path = dir.AppendASCII(key_filename);
18 std::string key_pkcs8;
19 bool success = base::ReadFileToString(key_path, &key_pkcs8);
20 if (!success) {
21 LOG(ERROR) << "Failed to read file " << key_path.value();
22 return scoped_ptr<crypto::RSAPrivateKey>();
23 }
24
25 const uint8* key_pkcs8_begin =
26 reinterpret_cast<const uint8*>(key_pkcs8.data());
27 std::vector<uint8> key_vector(key_pkcs8_begin,
28 key_pkcs8_begin + key_pkcs8.length());
29
30 scoped_ptr<crypto::RSAPrivateKey> private_key(
31 crypto::RSAPrivateKey::CreateSensitiveFromPrivateKeyInfo(slot,
32 key_vector));
33 LOG_IF(ERROR, !private_key) << "Could not create key from file "
34 << key_path.value();
35 return private_key.Pass();
36 }
37
38 } // namespace net
OLDNEW
« net/test/cert_test_util.h ('K') | « net/test/cert_test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698