OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 reinterpret_cast<const unsigned char*>(context.data()), | 549 reinterpret_cast<const unsigned char*>(context.data()), |
550 context.length(), out, outlen); | 550 context.length(), out, outlen); |
551 if (result != SECSuccess) { | 551 if (result != SECSuccess) { |
552 LogFailedNSSFunction(net_log_, "SSL_ExportKeyingMaterial", ""); | 552 LogFailedNSSFunction(net_log_, "SSL_ExportKeyingMaterial", ""); |
553 return MapNSSError(PORT_GetError()); | 553 return MapNSSError(PORT_GetError()); |
554 } | 554 } |
555 return OK; | 555 return OK; |
556 } | 556 } |
557 | 557 |
558 SSLClientSocket::NextProtoStatus | 558 SSLClientSocket::NextProtoStatus |
559 SSLClientSocketNSS::GetNextProto(std::string* proto) { | 559 SSLClientSocketNSS::GetNextProto(std::string* proto, |
| 560 std::string* server_protos) { |
560 *proto = next_proto_; | 561 *proto = next_proto_; |
| 562 *server_protos = server_protos_; |
561 return next_proto_status_; | 563 return next_proto_status_; |
562 } | 564 } |
563 | 565 |
564 int SSLClientSocketNSS::Connect(OldCompletionCallback* callback) { | 566 int SSLClientSocketNSS::Connect(OldCompletionCallback* callback) { |
565 EnterFunction(""); | 567 EnterFunction(""); |
566 DCHECK(transport_.get()); | 568 DCHECK(transport_.get()); |
567 DCHECK(next_handshake_state_ == STATE_NONE); | 569 DCHECK(next_handshake_state_ == STATE_NONE); |
568 DCHECK(!user_read_callback_); | 570 DCHECK(!user_read_callback_); |
569 DCHECK(!user_write_callback_); | 571 DCHECK(!user_write_callback_); |
570 DCHECK(!user_connect_callback_); | 572 DCHECK(!user_connect_callback_); |
(...skipping 2020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2591 } | 2593 } |
2592 | 2594 |
2593 if (that->next_proto_status_ == kNextProtoNegotiated) | 2595 if (that->next_proto_status_ == kNextProtoNegotiated) |
2594 break; | 2596 break; |
2595 | 2597 |
2596 // NSS checks that the data in |protos| is well formed, so we know that | 2598 // NSS checks that the data in |protos| is well formed, so we know that |
2597 // this doesn't cause us to jump off the end of the buffer. | 2599 // this doesn't cause us to jump off the end of the buffer. |
2598 i += len + 1; | 2600 i += len + 1; |
2599 } | 2601 } |
2600 | 2602 |
| 2603 that->server_protos_.assign( |
| 2604 reinterpret_cast<const char*>(protos), protos_len); |
| 2605 |
2601 // If we didn't find a protocol, we select the first one from our list. | 2606 // If we didn't find a protocol, we select the first one from our list. |
2602 if (that->next_proto_status_ != kNextProtoNegotiated) { | 2607 if (that->next_proto_status_ != kNextProtoNegotiated) { |
2603 that->next_proto_status_ = kNextProtoNoOverlap; | 2608 that->next_proto_status_ = kNextProtoNoOverlap; |
2604 that->next_proto_ = that->ssl_config_.next_protos[0]; | 2609 that->next_proto_ = that->ssl_config_.next_protos[0]; |
2605 } | 2610 } |
2606 | 2611 |
2607 memcpy(proto_out, that->next_proto_.data(), that->next_proto_.size()); | 2612 memcpy(proto_out, that->next_proto_.data(), that->next_proto_.size()); |
2608 *proto_out_len = that->next_proto_.size(); | 2613 *proto_out_len = that->next_proto_.size(); |
2609 return SECSuccess; | 2614 return SECSuccess; |
2610 } | 2615 } |
2611 | 2616 |
2612 void SSLClientSocketNSS::EnsureThreadIdAssigned() const { | 2617 void SSLClientSocketNSS::EnsureThreadIdAssigned() const { |
2613 base::AutoLock auto_lock(lock_); | 2618 base::AutoLock auto_lock(lock_); |
2614 if (valid_thread_id_ != base::kInvalidThreadId) | 2619 if (valid_thread_id_ != base::kInvalidThreadId) |
2615 return; | 2620 return; |
2616 valid_thread_id_ = base::PlatformThread::CurrentId(); | 2621 valid_thread_id_ = base::PlatformThread::CurrentId(); |
2617 } | 2622 } |
2618 | 2623 |
2619 bool SSLClientSocketNSS::CalledOnValidThread() const { | 2624 bool SSLClientSocketNSS::CalledOnValidThread() const { |
2620 EnsureThreadIdAssigned(); | 2625 EnsureThreadIdAssigned(); |
2621 base::AutoLock auto_lock(lock_); | 2626 base::AutoLock auto_lock(lock_); |
2622 return valid_thread_id_ == base::PlatformThread::CurrentId(); | 2627 return valid_thread_id_ == base::PlatformThread::CurrentId(); |
2623 } | 2628 } |
2624 | 2629 |
2625 } // namespace net | 2630 } // namespace net |
OLD | NEW |