Skip to content

Commit 890f8bf

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 52fb7d2 commit 890f8bf

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ext/openssl/ossl_ssl.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1536,7 +1536,10 @@ ossl_ssl_s_alloc(VALUE klass)
15361536
static VALUE
15371537
peer_ip_address(VALUE self)
15381538
{
1539-
VALUE remote_address = rb_funcall(rb_attr_get(self, id_i_io), rb_intern("remote_address"), 0);
1539+
VALUE io = rb_attr_get(self, id_i_io);
1540+
VALUE remote_address = rb_check_funcall(io, rb_intern("remote_address"), 0, NULL);
1541+
if (remote_address == Qundef)
1542+
return rb_str_new_cstr("(unsupported)");
15401543

15411544
return rb_funcall(remote_address, rb_intern("inspect_sockaddr"), 0);
15421545
}

0 commit comments

Comments
 (0)