GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: simplify ALPN code, remove indirection · nodejs/node@d433d34

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src/crypto
    • crypto_common.cc
    • crypto_common.h
    • crypto_tls.cc
Expand file treeCollapse file tree
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)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.