diff options
author | Fedor Indutny <fedor.indutny@gmail.com> | 2013-08-03 21:29:54 +0400 |
---|---|---|
committer | Fedor Indutny <fedor.indutny@gmail.com> | 2013-08-06 16:13:01 +0400 |
commit | 048e0e77e0c341407ecea364cbe26c8f77be48b8 (patch) | |
tree | 1f4a7da1cdd0ad521b2b40c8258da5c82bee8a0e /src/node_crypto_clienthello.cc | |
parent | 8e28193cc239a8389a1edda6810402005c1336cc (diff) | |
download | android-node-v8-048e0e77e0c341407ecea364cbe26c8f77be48b8.tar.gz android-node-v8-048e0e77e0c341407ecea364cbe26c8f77be48b8.tar.bz2 android-node-v8-048e0e77e0c341407ecea364cbe26c8f77be48b8.zip |
tls: asynchronous SNICallback
Make ClientHelloParser handle SNI extension, and extend `_tls_wrap.js`
to support loading SNI Context from both hello, and resumed session.
fix #5967
Diffstat (limited to 'src/node_crypto_clienthello.cc')
-rw-r--r-- | src/node_crypto_clienthello.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/node_crypto_clienthello.cc b/src/node_crypto_clienthello.cc index 5c1ecfaa97..424b30e5b9 100644 --- a/src/node_crypto_clienthello.cc +++ b/src/node_crypto_clienthello.cc @@ -123,6 +123,8 @@ void ClientHelloParser::ParseHeader(const uint8_t* data, size_t avail) { hello.session_id_ = session_id_; hello.session_size_ = session_size_; hello.has_ticket_ = tls_ticket_ != NULL && tls_ticket_size_ != 0; + hello.servername_ = servername_; + hello.servername_size_ = servername_size_; onhello_cb_(cb_arg_, hello); } @@ -134,6 +136,29 @@ void ClientHelloParser::ParseExtension(ClientHelloParser::ExtensionType type, // That's because we're heavily relying on OpenSSL to solve any problem with // incoming data. switch (type) { + case kServerName: + { + if (len < 2) + return; + uint16_t server_names_len = (data[0] << 8) + data[1]; + if (server_names_len + 2 > len) + return; + for (size_t offset = 2; offset < 2 + server_names_len; ) { + if (offset + 3 > len) + return; + uint8_t name_type = data[offset]; + if (name_type != kServernameHostname) + return; + uint16_t name_len = (data[offset + 1] << 8) + data[offset + 2]; + offset += 3; + if (offset + name_len > len) + return; + servername_ = data + offset; + servername_size_ = name_len; + offset += name_len; + } + } + break; case kTLSSessionTicket: tls_ticket_size_ = len; tls_ticket_ = data + len; |