Chromium Code Reviews| Index: net/socket/ssl_client_socket_openssl.cc |
| =================================================================== |
| --- net/socket/ssl_client_socket_openssl.cc (revision 141188) |
| +++ net/socket/ssl_client_socket_openssl.cc (working copy) |
| @@ -852,17 +852,17 @@ |
| const unsigned char* in, |
| unsigned int inlen) { |
| #if defined(OPENSSL_NPN_NEGOTIATED) |
| + // It's expected that a client will have a list of protocols that it |
|
agl
2012/06/08 14:23:14
I don't think that this comment is very clear. May
Johnny(Jianning) Ding
2012/06/11 13:27:19
That comment is copied from https://technotes.goog
agl
2012/06/11 16:02:02
The first half is, but it doesn't make sense in th
wtc
2012/06/12 17:50:30
jnd: I suggest simply removing this comment.
You
Johnny(Jianning) Ding
2012/06/13 09:31:20
Thanks for all your comments. Seems we should keep
|
| + // supports. If not, which means NPN is not supported. |
| if (ssl_config_.next_protos.empty()) { |
| *out = reinterpret_cast<uint8*>(const_cast<char*>("http/1.1")); |
| *outlen = 8; |
|
Ryan Sleevi
2012/06/08 18:16:29
nit: I think I preferred Joth's suggestion (use a
Johnny(Jianning) Ding
2012/06/11 13:27:19
Will change in next upload.
|
| - npn_status_ = SSLClientSocket::kNextProtoUnsupported; |
| + npn_status_ = kNextProtoUnsupported; |
|
agl
2012/06/08 14:23:14
This should be NoOverlap, not Unsupported. If we h
Ryan Sleevi
2012/06/08 18:16:29
agl: This does change the behaviour then between t
|
| return SSL_TLSEXT_ERR_OK; |
| } |
| // Assume there's no overlap between our protocols and the server's list. |
| - int status = OPENSSL_NPN_NO_OVERLAP; |
| - *out = const_cast<unsigned char*>(in) + 1; |
| - *outlen = in[0]; |
| + npn_status_ = kNextProtoNoOverlap; |
| // For each protocol in server preference order, see if we support it. |
| for (unsigned int i = 0; i < inlen; i += in[i] + 1) { |
| @@ -874,27 +874,23 @@ |
| // We find a match. |
| *out = const_cast<unsigned char*>(in) + i + 1; |
| *outlen = in[i]; |
| - status = OPENSSL_NPN_NEGOTIATED; |
| + npn_status_ = kNextProtoNegotiated; |
|
Ryan Sleevi
2012/06/08 18:16:29
nit: find -> found, since this comment appears aft
Johnny(Jianning) Ding
2012/06/11 13:27:19
will change in next upload.
On 2012/06/08 18:16:2
|
| break; |
| } |
| } |
| - if (status == OPENSSL_NPN_NEGOTIATED) |
| + if (npn_status_ == kNextProtoNegotiated) |
| break; |
| } |
| + // If we didn't find a protocol, we select the first one from our list. |
| + if (npn_status_ == kNextProtoNoOverlap) { |
| + *out = reinterpret_cast<uint8*>(const_cast<char*>( |
| + ssl_config_.next_protos[0].data())); |
| + *outlen = ssl_config_.next_protos[0].size(); |
| + } |
| + |
| npn_proto_.assign(reinterpret_cast<const char*>(*out), *outlen); |
| server_protos_.assign(reinterpret_cast<const char*>(in), inlen); |
| - switch (status) { |
| - case OPENSSL_NPN_NEGOTIATED: |
| - npn_status_ = SSLClientSocket::kNextProtoNegotiated; |
| - break; |
| - case OPENSSL_NPN_NO_OVERLAP: |
| - npn_status_ = SSLClientSocket::kNextProtoNoOverlap; |
| - break; |
| - default: |
| - NOTREACHED() << status; |
| - break; |
| - } |
| DVLOG(2) << "next protocol: '" << npn_proto_ << "' status: " << npn_status_; |
| #endif |
| return SSL_TLSEXT_ERR_OK; |