Project

General

Profile

Bug #1907

ssl_timeout cannot be set in HTTPS request

Added by lsegal (Loren Segal) about 10 years ago. Updated 21 days ago.

Status:
Closed
Priority:
Normal
ruby -v:
ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-darwin9.6.0]
[ruby-core:24812]

Description

=begin
Net::HTTPS defines SSL_ATTRIBUTES which, as I understand, are attributes that can be set on an HTTP object and includes ssl_timeout

However when applying these attributes on the SSLContext, the following exception is raised:

NoMethodError: undefined method ssl_timeout=' for #<OpenSSL::SSL::SSLContext:0x6511fc>
from /usr/local/lib/ruby19/1.9.1/openssl/ssl.rb:39:in
block in set_params'
from /usr/local/lib/ruby19/1.9.1/openssl/ssl.rb:39:in each'
from /usr/local/lib/ruby19/1.9.1/openssl/ssl.rb:39:in
set_params'
from /usr/local/lib/ruby19/1.9.1/net/http.rb:591:in connect'
from /usr/local/lib/ruby19/1.9.1/net/http.rb:574:in
do_start'
from /usr/local/lib/ruby19/1.9.1/net/http.rb:563:in start'
from /usr/local/lib/ruby19/1.9.1/net/http.rb:1094:in
request'
from (irb):16
from /usr/local/bin/irb:12:in `'

The code being run is:

require 'net/https'
http = Net::HTTP.new("example.com")
http.use_ssl = true
http.ssl_timeout = 1
http.request('hi') # exception is raised here

SSLContext does not implement ssl_timeout= but it does have timeout=, so this attribute should be handled specially, or perhaps be aliased in SSLContext?
=end

History

#1

Updated by mame (Yusuke Endoh) over 9 years ago

  • Assignee set to yugui (Yuki Sonoda)

=begin
Hi,

Net::HTTPS defines SSL_ATTRIBUTES which, as I understand, are attributes that can be set on an HTTP object and includes ssl_timeout

However when applying these attributes on the SSLContext, the following exception is raised:

I'm not familiar with net/https and openssl, but

perhaps be aliased in SSLContext?

I think it is reasonable because there are

  • SSLContext#timeout,
  • SSLContext#timeout=, and
  • SSLContext#ssl_timeout (as alias to SSLContext#timeout)

but not SSLContext#ssl_timeout=.

Adding `ssl_timeout=' may be considered as a new feature. But, the
symptom OP reported is certainly a bug, and adding it is most
appropriate fix the symptom, I think.

Yugui, may I commit the following patch?

diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
index fe6e74f..e70a868 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -1577,6 +1577,7 @@ Init_ossl_ssl()
for(i = 0; i < numberof(ossl_sslctx_attrs); i++)
rb_attr(cSSLContext, rb_intern(ossl_sslctx_attrs[i]), 1, 1, Qfalse);
rb_define_alias(cSSLContext, "ssl_timeout", "timeout");

  • rb_define_alias(cSSLContext, "ssl_timeout=", "timeout="); rb_define_method(cSSLContext, "initialize", ossl_sslctx_initialize, -1); rb_define_method(cSSLContext, "ssl_version=", ossl_sslctx_set_ssl_version, 1); rb_define_method(cSSLContext, "ciphers", ossl_sslctx_get_ciphers, 0);

--
Yusuke Endoh mame@tsg.ne.jp
=end

#2

Updated by yugui (Yuki Sonoda) over 9 years ago

=begin

may I commit the following patch?
OK.

2010/04/10 12:30 "Yusuke Endoh" redmine@ruby-lang.org:

Issue #1907 has been updated by Yusuke Endoh.

Assigned to set to Yuki Sonoda

Hi,

Net::HTTPS defines SSL_ATTRIBUTES which, as I understand, are attributes
that can be set on an HT...
I'm not familiar with net/https and openssl, but

perhaps be aliased in SSLContext?
I think it is reasonable because there are

  • SSLContext#timeout,
  • SSLContext#timeout=, and
  • SSLContext#ssl_timeout (as alias to SSLContext#timeout)

but not SSLContext#ssl_timeout=.

Adding `ssl_timeout=' may be considered as a new feature. But, the
symptom OP reported is certainly a bug, and adding it is most
appropriate fix the symptom, I think.

Yugui, may I commit the following patch?

diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
index fe6e74f..e70a868 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -1577,6 +1577,7 @@ Init_ossl_ssl()
for(i = 0; i < numberof(ossl_sslctx_attrs); i++)
rb_attr(cSSLContext, rb_intern(ossl_sslctx_attrs[i]), 1, 1, Qfalse);
rb_define_alias(cSSLContext, "ssl_timeout", "timeout");

  • rb_define_alias(cSSLContext, "ssl_timeout=", "timeout="); rb_define_method(cSSLContext, "initialize", ossl_sslctx_initialize, -1); rb_define_method(cSSLContext, "ssl_version=", ossl_sslctx_set_ssl_version, 1); rb_define_method(cSSLContext, "ciphers", ossl_sslctx_get_ciphers, 0);

--
Yusuke Endoh mame@tsg.ne.jp


http://redmine.ruby-lang.org/issues/show/1907


http://redmine.ruby-lang.org

> may I commit the following patch?
OK.
2010/04/10 12:30 "Yusuke Endoh" <redmine@ruby-lang.org>:Issue #1907 has been updated by Yusuke Endoh.

Assigned to set to Yuki Sonoda

Hi,
> Net::HTTPS defines SSL_ATTRIBUTES which, as I understand, are attributes that can be set on an HT...I'm not familiar with net/https and openssl, but
> perhaps be aliased in SSLContext?I think it is reasonable because there are

 - SSLContext#timeout,
 - SSLContext#timeout=, and
 - SSLContext#ssl_timeout (as alias to SSLContext#timeout)

but not SSLContext#ssl_timeout=.

Adding `ssl_timeout=' may be considered as a new feature.  But, the
symptom OP reported is certainly a bug, and adding it is most
appropriate fix the symptom, I think.


Yugui, may I commit the following patch?


diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
index fe6e74f..e70a868 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -1577,6 +1577,7 @@ Init_ossl_ssl()
    for(i = 0; i < numberof(ossl_sslctx_attrs); i++)
        rb_attr(cSSLContext, rb_intern(ossl_sslctx_attrs[i]), 1, 1, Qfalse);
    rb_define_alias(cSSLContext, "ssl_timeout", "timeout");

  •    rb_define_alias(cSSLContext, "ssl_timeout=", "timeout=");     rb_define_method(cSSLContext, "initialize",  ossl_sslctx_initialize, -1);     rb_define_method(cSSLContext, "ssl_version=", ossl_sslctx_set_ssl_version, 1);     rb_define_method(cSSLContext, "ciphers",     ossl_sslctx_get_ciphers, 0); -- Yusuke Endoh <mame@tsg.ne.jp> ---------------------------------------- http://redmine.ruby-lang.org/issues/show/1907---------------------------------------- http://redmine.ruby-lang.org

=end

#3

Updated by shyouhei (Shyouhei Urabe) about 9 years ago

  • Status changed from Open to Assigned

=begin

=end

#4

Updated by jeremyevans0 (Jeremy Evans) 21 days ago

  • Status changed from Assigned to Closed
  • Description updated (diff)

Also available in: Atom PDF