Skip to content

Commit c19ff32

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

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
@@ -1577,7 +1577,11 @@ ossl_ssl_s_alloc(VALUE klass)
15771577
static VALUE
15781578
peer_ip_address(VALUE self)
15791579
{
1580-
VALUE remote_address = rb_funcall(rb_attr_get(self, id_i_io), rb_intern("remote_address"), 0);
1580+
VALUE io = rb_attr_get(self, id_i_io);
1581+
if (!rb_respond_to(io, rb_intern("remote_address")))
1582+
return rb_str_new_cstr("(unsupported)");
1583+
1584+
VALUE remote_address = rb_funcall(io, rb_intern("remote_address"), 0);
15811585

15821586
return rb_funcall(remote_address, rb_intern("inspect_sockaddr"), 0);
15831587
}

0 commit comments

Comments
 (0)