| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 // This file includes code SSLClientSocketNSS::DoVerifyCertComplete() derived | 5 // This file includes code SSLClientSocketNSS::DoVerifyCertComplete() derived |
| 6 // from AuthCertificateCallback() in | 6 // from AuthCertificateCallback() in |
| 7 // mozilla/security/manager/ssl/src/nsNSSCallbacks.cpp. | 7 // mozilla/security/manager/ssl/src/nsNSSCallbacks.cpp. |
| 8 | 8 |
| 9 /* ***** BEGIN LICENSE BLOCK ***** | 9 /* ***** BEGIN LICENSE BLOCK ***** |
| 10 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 10 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 nss_fd_ = memio_CreateIOLayer(kRecvBufferSize); | 312 nss_fd_ = memio_CreateIOLayer(kRecvBufferSize); |
| 313 if (nss_fd_ == NULL) { | 313 if (nss_fd_ == NULL) { |
| 314 return ERR_OUT_OF_MEMORY; // TODO(port): map NSPR error code. | 314 return ERR_OUT_OF_MEMORY; // TODO(port): map NSPR error code. |
| 315 } | 315 } |
| 316 | 316 |
| 317 // Tell NSS who we're connected to | 317 // Tell NSS who we're connected to |
| 318 AddressList peer_address; | 318 AddressList peer_address; |
| 319 int err = transport_->GetPeerAddress(&peer_address); | 319 int err = transport_->GetPeerAddress(&peer_address); |
| 320 if (err != OK) | 320 if (err != OK) |
| 321 return err; | 321 return err; |
| 322 |
| 322 const struct addrinfo* ai = peer_address.head(); | 323 const struct addrinfo* ai = peer_address.head(); |
| 323 memio_SetPeerName(nss_fd_, ai->ai_addr, ai->ai_addrlen); | 324 |
| 325 PRNetAddr peername; |
| 326 memset(&peername, 0, sizeof(peername)); |
| 327 DCHECK_LE(ai->ai_addrlen, sizeof(peername)); |
| 328 size_t len = std::min(static_cast<size_t>(ai->ai_addrlen), sizeof(peername)); |
| 329 memcpy(&peername, ai->ai_addr, len); |
| 330 |
| 331 // Adjust the address family field for BSD, whose sockaddr |
| 332 // structure has a one-byte length and one-byte address family |
| 333 // field at the beginning. PRNetAddr has a two-byte address |
| 334 // family field at the beginning. |
| 335 peername.raw.family = ai->ai_addr->sa_family; |
| 336 |
| 337 memio_SetPeerName(nss_fd_, &peername); |
| 324 | 338 |
| 325 // Grab pointer to buffers | 339 // Grab pointer to buffers |
| 326 nss_bufs_ = memio_GetSecret(nss_fd_); | 340 nss_bufs_ = memio_GetSecret(nss_fd_); |
| 327 | 341 |
| 328 /* Create SSL state machine */ | 342 /* Create SSL state machine */ |
| 329 /* Push SSL onto our fake I/O socket */ | 343 /* Push SSL onto our fake I/O socket */ |
| 330 nss_fd_ = SSL_ImportFD(NULL, nss_fd_); | 344 nss_fd_ = SSL_ImportFD(NULL, nss_fd_); |
| 331 if (nss_fd_ == NULL) { | 345 if (nss_fd_ == NULL) { |
| 332 return ERR_OUT_OF_MEMORY; // TODO(port): map NSPR/NSS error code. | 346 return ERR_OUT_OF_MEMORY; // TODO(port): map NSPR/NSS error code. |
| 333 } | 347 } |
| (...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1408 } | 1422 } |
| 1409 PRErrorCode prerr = PR_GetError(); | 1423 PRErrorCode prerr = PR_GetError(); |
| 1410 if (prerr == PR_WOULD_BLOCK_ERROR) { | 1424 if (prerr == PR_WOULD_BLOCK_ERROR) { |
| 1411 return ERR_IO_PENDING; | 1425 return ERR_IO_PENDING; |
| 1412 } | 1426 } |
| 1413 LeaveFunction(""); | 1427 LeaveFunction(""); |
| 1414 return MapNSPRError(prerr); | 1428 return MapNSPRError(prerr); |
| 1415 } | 1429 } |
| 1416 | 1430 |
| 1417 } // namespace net | 1431 } // namespace net |
| OLD | NEW |