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

Side by Side Diff: net/socket/ssl_client_socket_openssl_unittest.cc

Issue 19579005: Move ReadFileToString to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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/proxy/proxy_resolver_v8_unittest.cc ('k') | net/socket/ssl_server_socket_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/socket/ssl_client_socket.h" 5 #include "net/socket/ssl_client_socket.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <openssl/bio.h> 10 #include <openssl/bio.h>
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 const SSLConfig kDefaultSSLConfig; 60 const SSLConfig kDefaultSSLConfig;
61 61
62 // Loads a PEM-encoded private key file into a scoped EVP_PKEY object. 62 // Loads a PEM-encoded private key file into a scoped EVP_PKEY object.
63 // |filepath| is the private key file path. 63 // |filepath| is the private key file path.
64 // |*pkey| is reset to the new EVP_PKEY on success, untouched otherwise. 64 // |*pkey| is reset to the new EVP_PKEY on success, untouched otherwise.
65 // Returns true on success, false on failure. 65 // Returns true on success, false on failure.
66 bool LoadPrivateKeyOpenSSL( 66 bool LoadPrivateKeyOpenSSL(
67 const base::FilePath& filepath, 67 const base::FilePath& filepath,
68 OpenSSLClientKeyStore::ScopedEVP_PKEY* pkey) { 68 OpenSSLClientKeyStore::ScopedEVP_PKEY* pkey) {
69 std::string data; 69 std::string data;
70 if (!file_util::ReadFileToString(filepath, &data)) { 70 if (!base::ReadFileToString(filepath, &data)) {
71 LOG(ERROR) << "Could not read private key file: " 71 LOG(ERROR) << "Could not read private key file: "
72 << filepath.value() << ": " << strerror(errno); 72 << filepath.value() << ": " << strerror(errno);
73 return false; 73 return false;
74 } 74 }
75 ScopedBIO bio( 75 ScopedBIO bio(
76 BIO_new_mem_buf( 76 BIO_new_mem_buf(
77 const_cast<char*>(reinterpret_cast<const char*>(data.data())), 77 const_cast<char*>(reinterpret_cast<const char*>(data.data())),
78 static_cast<int>(data.size()))); 78 static_cast<int>(data.size())));
79 if (!bio.get()) { 79 if (!bio.get()) {
80 LOG(ERROR) << "Could not allocate BIO for buffer?"; 80 LOG(ERROR) << "Could not allocate BIO for buffer?";
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 EXPECT_TRUE(sock_->IsConnected()); 270 EXPECT_TRUE(sock_->IsConnected());
271 271
272 EXPECT_TRUE(CheckSSLClientSocketSentCert()); 272 EXPECT_TRUE(CheckSSLClientSocketSentCert());
273 273
274 sock_->Disconnect(); 274 sock_->Disconnect();
275 EXPECT_FALSE(sock_->IsConnected()); 275 EXPECT_FALSE(sock_->IsConnected());
276 } 276 }
277 277
278 } // namespace 278 } // namespace
279 } // namespace net 279 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_resolver_v8_unittest.cc ('k') | net/socket/ssl_server_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698