Skip to content

Commit 5b50088

Browse files
authored
Fix: don't hardcode alpn protocol byte size (openssl) (#14769)
For some reason OpenSSL used to negotiate the protocol by itself, without invoking the select callback, or maybe it didn't respect the total bytesize when processing the alpn string. That changed in the 3.0.14 and other bugfix releases of OpenSSL, which exposed the bug.
1 parent e279b3c commit 5b50088

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/openssl/ssl/context.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ abstract class OpenSSL::SSL::Context
178178
{% if LibSSL.has_method?(:ssl_ctx_set_alpn_select_cb) %}
179179
alpn_cb = ->(ssl : LibSSL::SSL, o : LibC::Char**, olen : LibC::Char*, i : LibC::Char*, ilen : LibC::Int, data : Void*) {
180180
proto = Box(Bytes).unbox(data)
181-
ret = LibSSL.ssl_select_next_proto(o, olen, proto, 2, i, ilen)
181+
ret = LibSSL.ssl_select_next_proto(o, olen, proto, proto.size, i, ilen)
182182
if ret != LibSSL::OPENSSL_NPN_NEGOTIATED
183183
LibSSL::SSL_TLSEXT_ERR_NOACK
184184
else

0 commit comments

Comments
 (0)