Skip to content

Commit

Permalink
[fix] SSLSocket#alpn_protocol to be nil when not used
Browse files Browse the repository at this point in the history
fixes GH-287
  • Loading branch information
kares committed Feb 13, 2024
1 parent 0068b77 commit 892eb6c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/org/jruby/ext/openssl/SSLSocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,10 @@ private SSLEngine ossl_ssl_setup(final ThreadContext context, final boolean serv
@JRubyMethod(name = "alpn_protocol")
public IRubyObject alpn_protocol(final ThreadContext context) {
final String protocol = engine.getApplicationProtocol();
return protocol == null ? context.nil : RubyString.newString(context.runtime, protocol);
// null if it has not yet been determined if alpn might be used for this connection,
// an empty String if application protocols values will not be used,
if (protocol == null || protocol.isEmpty()) return context.nil;
return RubyString.newString(context.runtime, protocol);
}

@JRubyMethod(name = "sync")
Expand Down

0 comments on commit 892eb6c

Please sign in to comment.