OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_win.h" | 5 #include "net/socket/ssl_client_socket_win.h" |
6 | 6 |
7 #include <schnlsp.h> | 7 #include <schnlsp.h> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/lock.h" | |
13 #include "base/stl_util-inl.h" | 12 #include "base/stl_util-inl.h" |
14 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "base/synchronization/lock.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "net/base/cert_verifier.h" | 16 #include "net/base/cert_verifier.h" |
17 #include "net/base/connection_type_histograms.h" | 17 #include "net/base/connection_type_histograms.h" |
18 #include "net/base/host_port_pair.h" | 18 #include "net/base/host_port_pair.h" |
19 #include "net/base/io_buffer.h" | 19 #include "net/base/io_buffer.h" |
20 #include "net/base/net_log.h" | 20 #include "net/base/net_log.h" |
21 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
22 #include "net/base/ssl_cert_request_info.h" | 22 #include "net/base/ssl_cert_request_info.h" |
23 #include "net/base/ssl_connection_status_flags.h" | 23 #include "net/base/ssl_connection_status_flags.h" |
24 #include "net/base/ssl_info.h" | 24 #include "net/base/ssl_info.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 STLDeleteContainerPairSecondPointers(client_cert_creds_.begin(), | 142 STLDeleteContainerPairSecondPointers(client_cert_creds_.begin(), |
143 client_cert_creds_.end()); | 143 client_cert_creds_.end()); |
144 } | 144 } |
145 | 145 |
146 int GetHandle(PCCERT_CONTEXT client_cert, | 146 int GetHandle(PCCERT_CONTEXT client_cert, |
147 int ssl_version_mask, | 147 int ssl_version_mask, |
148 CredHandle** handle_ptr) { | 148 CredHandle** handle_ptr) { |
149 DCHECK(0 < ssl_version_mask && | 149 DCHECK(0 < ssl_version_mask && |
150 ssl_version_mask < arraysize(anonymous_creds_)); | 150 ssl_version_mask < arraysize(anonymous_creds_)); |
151 CredHandleClass* handle; | 151 CredHandleClass* handle; |
152 AutoLock lock(lock_); | 152 base::AutoLock lock(lock_); |
153 if (client_cert) { | 153 if (client_cert) { |
154 CredHandleMapKey key = std::make_pair(client_cert, ssl_version_mask); | 154 CredHandleMapKey key = std::make_pair(client_cert, ssl_version_mask); |
155 CredHandleMap::const_iterator it = client_cert_creds_.find(key); | 155 CredHandleMap::const_iterator it = client_cert_creds_.find(key); |
156 if (it == client_cert_creds_.end()) { | 156 if (it == client_cert_creds_.end()) { |
157 handle = new CredHandleClass; | 157 handle = new CredHandleClass; |
158 client_cert_creds_[key] = handle; | 158 client_cert_creds_[key] = handle; |
159 } else { | 159 } else { |
160 handle = it->second; | 160 handle = it->second; |
161 } | 161 } |
162 } else { | 162 } else { |
(...skipping 14 matching lines...) Expand all Loading... |
177 // int ssl_version_mask | 177 // int ssl_version_mask |
178 typedef std::pair<PCCERT_CONTEXT, int> CredHandleMapKey; | 178 typedef std::pair<PCCERT_CONTEXT, int> CredHandleMapKey; |
179 | 179 |
180 typedef std::map<CredHandleMapKey, CredHandleClass*> CredHandleMap; | 180 typedef std::map<CredHandleMapKey, CredHandleClass*> CredHandleMap; |
181 | 181 |
182 // Returns OK on success or a network error code on failure. | 182 // Returns OK on success or a network error code on failure. |
183 static int InitializeHandle(CredHandle* handle, | 183 static int InitializeHandle(CredHandle* handle, |
184 PCCERT_CONTEXT client_cert, | 184 PCCERT_CONTEXT client_cert, |
185 int ssl_version_mask); | 185 int ssl_version_mask); |
186 | 186 |
187 Lock lock_; | 187 base::Lock lock_; |
188 | 188 |
189 // Anonymous (no client certificate) CredHandles for all possible | 189 // Anonymous (no client certificate) CredHandles for all possible |
190 // combinations of SSL versions. Defined as an array for fast lookup. | 190 // combinations of SSL versions. Defined as an array for fast lookup. |
191 CredHandleClass anonymous_creds_[SSL_VERSION_MASKS]; | 191 CredHandleClass anonymous_creds_[SSL_VERSION_MASKS]; |
192 | 192 |
193 // CredHandles that use a client certificate. | 193 // CredHandles that use a client certificate. |
194 CredHandleMap client_cert_creds_; | 194 CredHandleMap client_cert_creds_; |
195 }; | 195 }; |
196 | 196 |
197 static base::LazyInstance<CredHandleTable> g_cred_handle_table( | 197 static base::LazyInstance<CredHandleTable> g_cred_handle_table( |
(...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1513 UpdateConnectionTypeHistograms(CONNECTION_SSL_MD2_CA); | 1513 UpdateConnectionTypeHistograms(CONNECTION_SSL_MD2_CA); |
1514 } | 1514 } |
1515 | 1515 |
1516 void SSLClientSocketWin::FreeSendBuffer() { | 1516 void SSLClientSocketWin::FreeSendBuffer() { |
1517 SECURITY_STATUS status = FreeContextBuffer(send_buffer_.pvBuffer); | 1517 SECURITY_STATUS status = FreeContextBuffer(send_buffer_.pvBuffer); |
1518 DCHECK(status == SEC_E_OK); | 1518 DCHECK(status == SEC_E_OK); |
1519 memset(&send_buffer_, 0, sizeof(send_buffer_)); | 1519 memset(&send_buffer_, 0, sizeof(send_buffer_)); |
1520 } | 1520 } |
1521 | 1521 |
1522 } // namespace net | 1522 } // namespace net |
OLD | NEW |