Skip to content

Commit 1eb4b57

Browse files
committed
ssl: allow underlying socket to not implement #remote_address
The result value is only used for generating an informative error message. Let's just say "unsupported" if it's not available.
1 parent 41661db commit 1eb4b57

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ext/openssl/ossl_ssl.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1583,7 +1583,11 @@ ossl_ssl_s_alloc(VALUE klass)
15831583
static VALUE
15841584
peer_ip_address(VALUE self)
15851585
{
1586-
VALUE remote_address = rb_funcall(rb_attr_get(self, id_i_io), rb_intern("remote_address"), 0);
1586+
VALUE io = rb_attr_get(self, id_i_io);
1587+
if (!rb_respond_to(io, rb_intern("remote_address")))
1588+
return rb_str_new_cstr("(unsupported)");
1589+
1590+
VALUE remote_address = rb_funcall(io, rb_intern("remote_address"), 0);
15871591

15881592
return rb_funcall(remote_address, rb_intern("inspect_sockaddr"), 0);
15891593
}

0 commit comments

Comments
 (0)