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

Unified 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: Fixed gyp file. 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 side-by-side diff with in-line comments
Download patch
« net/test/cert_test_util.h ('K') | « net/test/cert_test_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/test/cert_test_util_nss.cc
diff --git a/net/test/cert_test_util_nss.cc b/net/test/cert_test_util_nss.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8b7a4ed3439ab5f6397d7b2d3e374c513bbe9b71
--- /dev/null
+++ b/net/test/cert_test_util_nss.cc
@@ -0,0 +1,39 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/test/cert_test_util.h"
+
+#include "base/file_util.h"
+#include "base/files/file_path.h"
+#include "base/path_service.h"
+#include "crypto/rsa_private_key.h"
+
+namespace net {
+
+scoped_ptr<crypto::RSAPrivateKey> ImportSensitiveKeyFromFile(
+ const base::FilePath& dir,
+ const std::string& key_filename,
+ PK11SlotInfo* slot) {
+ base::FilePath key_path = dir.AppendASCII(key_filename);
+ std::string key_pkcs8;
+ bool success = base::ReadFileToString(key_path, &key_pkcs8);
+ if (!success) {
+ LOG(ERROR) << "Failed to read file " << key_path.value();
+ return scoped_ptr<crypto::RSAPrivateKey>();
+ }
+
+ const uint8* key_pkcs8_begin =
+ reinterpret_cast<const uint8*>(key_pkcs8.data());
+ std::vector<uint8> key_vector(key_pkcs8_begin,
+ key_pkcs8_begin + key_pkcs8.length());
+
+ scoped_ptr<crypto::RSAPrivateKey> private_key(
+ crypto::RSAPrivateKey::CreateSensitiveFromPrivateKeyInfo(slot,
+ key_vector));
+ LOG_IF(ERROR, !private_key) << "Could not create key from file "
+ << key_path.value();
+ return private_key.Pass();
+}
+
+} // namespace net
« 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