Граф коммитов

630 Коммитов

Автор SHA1 Сообщение Дата
normal 9fbf488746 openssl: use RB_GC_GUARD instead of volatile
From doc/extension.rdoc:
>
> Using the RB_GC_GUARD macro is preferable to using the "volatile"
> keyword in C.  RB_GC_GUARD has the following advantages:
>
> 1) the intent of the macro use is clear
>
> 2) RB_GC_GUARD only affects its call site, "volatile" generates some
>    extra code every time the variable is used, hurting optimization.
>
> 3) "volatile" implementations may be buggy/inconsistent in some
>    compilers and architectures. RB_GC_GUARD is customizable for broken
>    systems/compilers without those without negatively affecting other
>    systems.

* ext/openssl/ossl_asn1.c (ossl_asn1_traverse, ossl_asn1_decode,
  ossl_asn1_decode_all): use RB_GC_GUARD instead of volatile
  [ruby-core:69371] [Bug #11185]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-27 01:09:11 +00:00
nobu bea4ccb2db ossl_asn1.c: [DOC] Fix typo [skip ci]
* ext/openssl/ossl_asn1.c (Init_ossl_asn1): [DOC] Fix typo
  "recieved" to "received".  [Fix GH-913]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-27 00:38:11 +00:00
hsbt 325a50fc57 * ext/openssl/*: use license instead of licence.
[fix GH-876][ci skip] Patch by @davydovanton
* lib/net/https.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-20 03:55:09 +00:00
nobu 038c0e5a80 ext: suppress warnings
* ext/{etc,openssl,tk}: Adding parens and comparisons around
  assignments to get rid of Wparentheses warnings.  [Fix GH-875]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-19 03:19:20 +00:00
nagachika 599bfa7233 * ext/openssl/lib/openssl/ssl.rb: stricter hostname verification
following RFC 6125. with the patch provided by Tony Arcieri and
  Hiroshi Nakamura [ruby-core:61545] [Bug #9644]
* test/openssl/test_ssl.rb: add tests for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-13 13:09:18 +00:00
normal c18df6d87c connect_nonblock supports "exception: false"
This is for consistency with accept_nonblock arguments and gives a
minor speedup from avoiding exceptions.
[ruby-core:68838] [Feature #11024]

* ext/openssl/ossl_ssl.c (ossl_ssl_connect_nonblock):
  support `exception: false'
* (get_no_exception): move function location
* ext/socket/socket.c (sock_connect_nonblock):
  support `exception: false'
* test/openssl/test_pair.rb (test_connect_accept_nonblock_no_exception):
  test `exception: false' on connect,
  rename from `test_accept_nonblock_no_exception'
* test/socket/test_nonblock.rb (test_connect_nonblock_no_exception):
  new test

Benchmark results:

default            0.050000   0.100000   0.150000 (  0.151307)
exception: false   0.030000   0.080000   0.110000 (  0.108840)

----------------------------8<-----------------------
require 'socket'
require 'benchmark'
require 'io/wait'
require 'tmpdir'

host = '127.0.0.1'
serv = TCPServer.new(host, 0) # UNIX sockets may not hit EINPROGRESS

nr = 5000 # few iterations to avoid running out of ports

addr = serv.getsockname
pid = fork do
  begin
    serv.accept.close
  rescue => e
    warn "#$$: #{e.message} (#{e.class})"
  end while true
end
at_exit { Process.kill(:TERM, pid) }
serv.close

Benchmark.bmbm do |x|
  x.report("default") do
    nr.times do
      s = Socket.new(:INET, :STREAM)
      s.setsockopt(:SOL_SOCKET, :SO_REUSEADDR, 1)
      begin
        s.connect_nonblock(addr)
      rescue IO::WaitWritable
        s.wait_writable
      end
      s.close
    end
  end
  x.report("exception: false") do
    nr.times do
      s = Socket.new(:INET, :STREAM)
      s.setsockopt(:SOL_SOCKET, :SO_REUSEADDR, 1)
      case s.connect_nonblock(addr, exception: false)
      when :wait_writable
        s.wait_writable
      end
      s.close
    end
  end
end

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50254 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-12 01:41:51 +00:00
normal 9941f348e0 accept_nonblock: favor rb_hash_lookup2 to avoid Hash#default
* ext/socket/init.c (rsock_s_accept_nonblock): use rb_hash_lookup2
* ext/openssl/ossl_ssl.c (get_no_exception): new function
  (ossl_ssl_accept_nonblock): use get_no_exception
  (ossl_ssl_read_internal): ditto
  (ossl_ssl_write_nonblock): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-12 22:04:24 +00:00
normal ddf2558a16 ext/openssl/ossl_ssl.c: predefine wait_*able symbols
This leads to a size reduction in openssl.so and reduces the
chance of bugs due to typos.

         text    data     bss     dec     hex
before: 333022   13164    3312  349498   5553a
 after: 332790   13164    3232  349186   55402

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49954 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-12 22:03:53 +00:00
normal aaf2d070a8 accept_nonblock supports "exception: false"
This is analogous to functionality found in IO#read_nonblock and
IO#wait_nonblock.  Raising exceptions for common failures on
non-blocking servers is expensive and makes $DEBUG too noisy.

Benchmark results:
                                    user     system      total        real
default                         2.790000   0.870000   3.660000 (  3.671597)
exception: false                1.120000   0.800000   1.920000 (  1.922032)
exception: false (cached arg)   0.820000   0.770000   1.590000 (  1.589267)
--------------------- benchmark script ------------------------
require 'socket'
require 'benchmark'
require 'tmpdir'
nr = 1000000
Dir.mktmpdir('nb_bench') do |path|
  sock_path = "#{path}/test.sock"
  s = UNIXServer.new(sock_path)
  Benchmark.bmbm do |x|
    x.report("default") do
      nr.times do
        begin
          s.accept_nonblock
        rescue IO::WaitReadable
        end
      end
    end
    x.report("exception: false") do
      nr.times do
        begin
          s.accept_nonblock(exception: false)
        rescue IO::WaitReadable
          abort "should not raise"
        end
      end
    end
    x.report("exception: false (cached arg)") do
      arg = { exception: false }
      nr.times do
        begin
          s.accept_nonblock(arg)
        rescue IO::WaitReadable
          abort "should not raise"
        end
      end
    end
  end
end

* ext/socket/init.c (rsock_s_accept_nonblock):
  support exception: false
  [ruby-core:66385] [Feature #10532]
* ext/socket/init.c (rsock_init_socket_init): define new symbols
* ext/socket/rubysocket.h: adjust prototype
* ext/socket/socket.c (sock_accept_nonblock): support exception: false
* ext/openssl/ossl_ssl.c (ossl_ssl_accept_nonblock): ditto
* ext/socket/socket.c (Init_socket): adjust accept_nonblock definition
* ext/openssl/ossl_ssl.c (Init_ossl_ssl): ditto
* ext/socket/tcpserver.c (rsock_init_tcpserver): ditto
* ext/socket/unixserver.c (rsock_init_unixserver): ditto
* ext/socket/tcpserver.c (tcp_accept_nonblock): adjust
  rsock_s_accept_nonblock call
* ext/socket/unixserver.c (unix_accept_nonblock): ditto
* ext/openssl/ossl_ssl.c (ossl_start_ssl): support no_exception
* ext/openssl/ossl_ssl.c (ossl_ssl_connect): adjust ossl_start_ssl call
* ext/openssl/ossl_ssl.c (ossl_ssl_connect_nonblock): ditto
* ext/openssl/ossl_ssl.c (ossl_ssl_accept): ditto
* test/socket/test_nonblock.rb (test_accept_nonblock): test for
  "exception :false"
* test/socket/test_tcp.rb (test_accept_nonblock): new test
* test/socket/test_unix.rb (test_accept_nonblock): ditto
* test/openssl/test_pair.rb (test_accept_nonblock_no_exception): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49948 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-12 03:03:04 +00:00
nobu c5d781dded ossl_bn.c: [DOC] expand rdocs [ci skip]
* ext/openssl/ossl_bn.c: [DOC] expand rdocs as RDoc does not
  expand C-preprocessor macros.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-21 23:28:47 +00:00
nobu 97f9589c4b ossl_asn1.c: fix doc
* ext/openssl/ossl_asn1.c (ossl_asn1obj_get_oid): [DOC] fix
  notation, an instance method but not a class method.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-21 22:56:06 +00:00
zzak b0317ee815 [DOC] Backport ruby/openssl@86eb721 [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49678 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-21 19:06:17 +00:00
nobu 16294913f7 use rb_funcallv
* use rb_funcallv() for no arguments call instead of variadic
  rb_funcall().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-16 04:08:52 +00:00
nobu 25455e611c openssl: check RAND_edg to support libressl
* ext/openssl/extconf.rb: check RAND_edg to support libressl.
* ext/openssl/ossl_rand.c (ossl_rand_egd): define only if RAND_edg
  is available.  [Fix GH-829]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-12 09:34:02 +00:00
hsbt f0577b7563 * ext/openssl/ossl.h: avoid to build failure of Windows environment.
* ext/openssl/ossl_ssl_session.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-03 02:50:31 +00:00
hsbt 2758be26bb * ext/openssl/ossl.h: Make `SSL_SESSION_cmp` use `CRYPTO_memcmp`
[fix GH-591] Patch by @PiPeep
* ext/openssl/ossl_ssl_session.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-03 01:14:56 +00:00
nobu debedd371a ossl_cipher.c: workaround of OpenSSL API
* ext/openssl/ossl_cipher.c (ossl_cipher_update_long): update huge
  data gradually not to exceed INT_MAX.  workaround of OpenSSL API
  limitation.  [ruby-core:67043] [Bug #10633]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48923 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-23 02:42:16 +00:00
akr ecedd3b224 Update dependencies.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-19 13:34:54 +00:00
nobu 0c71e2808e ossl_x509store.c: typed data
* ext/openssl/ossl_x509store.c (ossl_x509stctx_type): use typed
  data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-13 00:06:54 +00:00
nobu a3fa871534 ossl_x509store.c: typed data
* ext/openssl/ossl_x509store.c (ossl_x509store_type): use typed
  data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-13 00:06:48 +00:00
nobu 7db35b0399 ossl_x509revoked.c: typed data
* ext/openssl/ossl_x509revoked.c (ossl_x509rev_type): use typed
  data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 23:59:36 +00:00
nobu 0b671673dc ossl_x509req.c: typed data
* ext/openssl/ossl_x509req.c (ossl_x509req_type): use typed data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48815 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 23:59:28 +00:00
nobu a6eb21f849 ossl_x509name.c: typed data
* ext/openssl/ossl_x509name.c (ossl_x509name_type): use typed data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 23:59:19 +00:00
nobu cfde2808ae ossl_x509ext.c: typed data
* ext/openssl/ossl_x509ext.c (ossl_x509extfactory_type): use typed
  data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 23:46:42 +00:00
nobu 3d0cbeaddd ossl_x509ext.c: typed data
* ext/openssl/ossl_x509ext.c (ossl_x509ext_type): use typed data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 23:46:30 +00:00
nobu eb2cdab02f ossl_x509crl.c: typed data
* ext/openssl/ossl_x509crl.c (ossl_x509crl_type): use typed data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 23:39:04 +00:00
nobu 3bc78d5bd8 ossl_x509cert.c: typed data
* ext/openssl/ossl_x509cert.c (ossl_x509_type): use typed data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 23:38:55 +00:00
nobu c3fdb1c3bd ossl_x509attr.c: typed data
* ext/openssl/ossl_x509attr.c (ossl_x509attr_type): use typed data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 23:38:44 +00:00
nobu 2e78e44f59 ossl_pkey_ec.c: typed data
* ext/openssl/ossl_pkey_ec.c (ossl_ec_point_type): use typed data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 23:19:24 +00:00
nobu 13448fdc6b ossl_pkey_ec.c: typed data
* ext/openssl/ossl_pkey_ec.c (ossl_ec_group_type): use typed data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 23:19:13 +00:00
nobu 68c8994a69 ossl_pkey.c: typed data
* ext/openssl/ossl_pkey.c (ossl_evp_pkey_type): use typed data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48806 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 23:19:07 +00:00
nobu bf368e4f48 ossl_pkcs7.c: typed data
* ext/openssl/ossl_pkcs7.c (ossl_pkcs7_recip_info_type): use typed
  data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 22:38:01 +00:00
nobu ba19bcdda4 ossl_pkcs7.c: typed data
* ext/openssl/ossl_pkcs7.c (ossl_pkcs7_signer_info_type): use
  typed data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48804 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 22:37:58 +00:00
nobu b8897cd60f ossl_pkcs7.c: typed data
* ext/openssl/ossl_pkcs7.c (ossl_pkcs7_type): use typed data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 22:37:55 +00:00
nobu 374fe20e4f ossl_pkcs12.c: typed data
* ext/openssl/ossl_pkcs12.c (ossl_pkcs12_type): use typed data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48802 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 22:37:53 +00:00
nobu cd96afe993 ossl_ssl.c: typed data
* ext/openssl/ossl_ssl.c (ossl_ssl_type): use typed data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 21:58:34 +00:00
nobu 060e693738 ossl_ssl.c: typed data
* ext/openssl/ossl_ssl.c (ossl_sslctx_type): use typed data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 21:58:31 +00:00
nobu d064e7c857 ossl_ssl_session.c: typed data
* ext/openssl/ossl_ssl_session.c (ossl_ssl_session_type): use
  typed data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 21:58:25 +00:00
nobu 457cd40f30 ossl_ocsp.c: typed data
* ext/openssl/ossl_ocsp.c (ossl_ocsp_certid_type): use typed data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 21:58:22 +00:00
nobu e97e41e34a ossl_ocsp.c: typed data
* ext/openssl/ossl_ocsp.c (ossl_ocsp_basicresp_type): use typed
  data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 21:58:17 +00:00
nobu c3202f63b1 ossl_ocsp.c: typed data
* ext/openssl/ossl_ocsp.c (ossl_ocsp_response_type): use typed
  data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 21:58:11 +00:00
nobu 4bb6cb76f2 ossl_ocsp.c: typed data
* ext/openssl/ossl_ocsp.c (ossl_ocsp_request_type): use typed
  data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 21:58:07 +00:00
nobu a6d16bdc0f ossl_ns_spki.c: typed data
* ext/openssl/ossl_ns_spki.c (ossl_netscape_spki_type): use typed
  data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 21:58:03 +00:00
nobu c5de5573c1 ossl_hmac.c: typed data
* ext/openssl/ossl_hmac.c (ossl_hmac_type): use typed data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 21:57:56 +00:00
nobu b0a379e3b0 ossl_engine.c: typed data
* ext/openssl/ossl_engine.c (ossl_engine_type): use typed data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 21:57:49 +00:00
nobu cfa7024e25 ossl_digest.c: typed data
* ext/openssl/ossl_digest.c (ossl_digest_type): use typed data.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 21:57:44 +00:00
nobu 0ae6db41ca ossl_ssl.h: accessor macros
* ext/openssl/ossl_ssl.c (GetSSLCTX): accessor macro.
* ext/openssl/ossl_ssl.h (GetSSL): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 21:57:33 +00:00
nobu e580a631be use 0 for reserved
use 0 for rb_data_type_t::reserved instead of NULL, since its type
may be changed in the future and possibly not a pointer type.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-01 06:38:04 +00:00
akr 6ca202fcee Update dependency.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-21 03:04:44 +00:00
usa c1bad60408 * ext/openssl/lib/openssl/x509.rb
(OpenSSL::X509::Name::RFC2253DN::StringChar): get rid of a false
  positive assertion in ripper's test.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-20 15:39:03 +00:00