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

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: Addressed comments. 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
« no previous file with comments | « 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 #include "crypto/rsa_private_key.h"
11
12 namespace net {
13
14 scoped_ptr<crypto::RSAPrivateKey> ImportSensitiveKeyFromFile(
15 const base::FilePath& dir,
16 const std::string& key_filename,
17 PK11SlotInfo* slot) {
18 base::FilePath key_path = dir.AppendASCII(key_filename);
19 std::string key_pkcs8;
20 bool success = base::ReadFileToString(key_path, &key_pkcs8);
21 if (!success) {
22 LOG(ERROR) << "Failed to read file " << key_path.value();
23 return scoped_ptr<crypto::RSAPrivateKey>();
24 }
25
26 const uint8* key_pkcs8_begin =
27 reinterpret_cast<const uint8*>(key_pkcs8.data());
28 std::vector<uint8> key_vector(key_pkcs8_begin,
29 key_pkcs8_begin + key_pkcs8.length());
30
31 scoped_ptr<crypto::RSAPrivateKey> private_key(
32 crypto::RSAPrivateKey::CreateSensitiveFromPrivateKeyInfo(slot,
33 key_vector));
34 LOG_IF(ERROR, !private_key) << "Could not create key from file "
35 << key_path.value();
36 return private_key.Pass();
37 }
38
39 } // namespace net
OLDNEW
« no previous file with comments | « net/test/cert_test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698