Skip to content

Commit 892eb6c

Browse files
committed
[fix] SSLSocket#alpn_protocol to be nil when not used
fixes GH-287
1 parent 0068b77 commit 892eb6c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/org/jruby/ext/openssl/SSLSocket.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,10 @@ private SSLEngine ossl_ssl_setup(final ThreadContext context, final boolean serv
244244
@JRubyMethod(name = "alpn_protocol")
245245
public IRubyObject alpn_protocol(final ThreadContext context) {
246246
final String protocol = engine.getApplicationProtocol();
247-
return protocol == null ? context.nil : RubyString.newString(context.runtime, protocol);
247+
// null if it has not yet been determined if alpn might be used for this connection,
248+
// an empty String if application protocols values will not be used,
249+
if (protocol == null || protocol.isEmpty()) return context.nil;
250+
return RubyString.newString(context.runtime, protocol);
248251
}
249252

250253
@JRubyMethod(name = "sync")

0 commit comments

Comments
 (0)