Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d433d34

Browse filesBrowse files
bnoordhuisdanielleadams
authored andcommitted
src: simplify ALPN code, remove indirection
PR-URL: #44875 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent 4fe060e commit d433d34
Copy full SHA for d433d34

File tree

Expand file treeCollapse file tree

3 files changed

+4
-12
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+4
-12
lines changed
Open diff view settings
Collapse file

‎src/crypto/crypto_common.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_common.cc
-6Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,6 @@ void LogSecret(
8989
keylog_cb(ssl.get(), line.c_str());
9090
}
9191

92-
bool SetALPN(const SSLPointer& ssl, std::string_view alpn) {
93-
return SSL_set_alpn_protos(ssl.get(),
94-
reinterpret_cast<const uint8_t*>(alpn.data()),
95-
alpn.length()) == 0;
96-
}
97-
9892
MaybeLocal<Value> GetSSLOCSPResponse(
9993
Environment* env,
10094
SSL* ssl,
Collapse file

‎src/crypto/crypto_common.h‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_common.h
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ void LogSecret(
3333
const unsigned char* secret,
3434
size_t secretlen);
3535

36-
// TODO(tniessen): use std::u8string_view when we switch to C++20.
37-
bool SetALPN(const SSLPointer& ssl, std::string_view alpn);
38-
3936
v8::MaybeLocal<v8::Value> GetSSLOCSPResponse(
4037
Environment* env,
4138
SSL* ssl,
Collapse file

‎src/crypto/crypto_tls.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_tls.cc
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,17 +1529,18 @@ void TLSWrap::SetALPNProtocols(const FunctionCallbackInfo<Value>& args) {
15291529
if (args.Length() < 1 || !Buffer::HasInstance(args[0]))
15301530
return env->ThrowTypeError("Must give a Buffer as first argument");
15311531

1532+
SSL* ssl = w->ssl_.get();
15321533
if (w->is_client()) {
1533-
ArrayBufferViewContents<char> protos(args[0].As<ArrayBufferView>());
1534-
CHECK(SetALPN(w->ssl_, {protos.data(), protos.length()}));
1534+
ArrayBufferViewContents<uint8_t> protos(args[0].As<ArrayBufferView>());
1535+
CHECK_EQ(0, SSL_set_alpn_protos(ssl, protos.data(), protos.length()));
15351536
} else {
15361537
CHECK(
15371538
w->object()->SetPrivate(
15381539
env->context(),
15391540
env->alpn_buffer_private_symbol(),
15401541
args[0]).FromJust());
15411542
// Server should select ALPN protocol from list of advertised by client
1542-
SSL_CTX_set_alpn_select_cb(SSL_get_SSL_CTX(w->ssl_.get()),
1543+
SSL_CTX_set_alpn_select_cb(SSL_get_SSL_CTX(ssl),
15431544
SelectALPNCallback,
15441545
nullptr);
15451546
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.