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 // OpenSSL binding for SSLClientSocket. The class layout and general principle | 5 // OpenSSL binding for SSLClientSocket. The class layout and general principle |
6 // of operation is derived from SSLClientSocketNSS. | 6 // of operation is derived from SSLClientSocketNSS. |
7 | 7 |
8 #include "net/socket/ssl_client_socket_openssl.h" | 8 #include "net/socket/ssl_client_socket_openssl.h" |
9 | 9 |
10 #include <errno.h> | 10 #include <errno.h> |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 openssl_chain_.reset(NULL); | 290 openssl_chain_.reset(NULL); |
291 os_chain_ = NULL; | 291 os_chain_ = NULL; |
292 | 292 |
293 if (!chain) | 293 if (!chain) |
294 return; | 294 return; |
295 | 295 |
296 // sk_X509_dup does not increase reference count on the certs in the stack. | 296 // sk_X509_dup does not increase reference count on the certs in the stack. |
297 openssl_chain_.reset(sk_X509_dup(chain)); | 297 openssl_chain_.reset(sk_X509_dup(chain)); |
298 | 298 |
299 std::vector<base::StringPiece> der_chain; | 299 std::vector<base::StringPiece> der_chain; |
300 for (int i = 0; i < sk_X509_num(openssl_chain_.get()); ++i) { | 300 for (size_t i = 0; i < sk_X509_num(openssl_chain_.get()); ++i) { |
301 X509* x = sk_X509_value(openssl_chain_.get(), i); | 301 X509* x = sk_X509_value(openssl_chain_.get(), i); |
302 | 302 |
303 // Increase the reference count for the certs in openssl_chain_. | 303 // Increase the reference count for the certs in openssl_chain_. |
304 CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509); | 304 CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509); |
305 | 305 |
306 unsigned char* cert_data = NULL; | 306 unsigned char* cert_data = NULL; |
307 int cert_data_length = i2d_X509(x, &cert_data); | 307 int cert_data_length = i2d_X509(x, &cert_data); |
308 if (cert_data_length && cert_data) | 308 if (cert_data_length && cert_data) |
309 der_chain.push_back(base::StringPiece(reinterpret_cast<char*>(cert_data), | 309 der_chain.push_back(base::StringPiece(reinterpret_cast<char*>(cert_data), |
310 cert_data_length)); | 310 cert_data_length)); |
(...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1506 return socket->MaybeReplayTransportError( | 1506 return socket->MaybeReplayTransportError( |
1507 bio, cmd, argp, argi, argl, retvalue); | 1507 bio, cmd, argp, argi, argl, retvalue); |
1508 } | 1508 } |
1509 | 1509 |
1510 scoped_refptr<X509Certificate> | 1510 scoped_refptr<X509Certificate> |
1511 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { | 1511 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { |
1512 return server_cert_; | 1512 return server_cert_; |
1513 } | 1513 } |
1514 | 1514 |
1515 } // namespace net | 1515 } // namespace net |
OLD | NEW |