| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |