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

358 Коммитов

Автор SHA1 Сообщение Дата
hsbt 6447d061f5 * test/openssl/test_pkey_ec.rb: ignored tests with old OpenSSL.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-13 09:33:33 +00:00
nobu af06381332 test/openssl: skip old OpenSSL
* test/openssl/utils.rb (OpenSSL::TestUtils): ignore out-of-date
  OpenSSL before 1.0.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-13 03:05:43 +00:00
nobu 88cea9f7e2 revert r48819
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-13 03:05:31 +00:00
nobu 58d992ec44 test_ocsp.rb: run separately
* test/openssl/test_ocsp.rb (test_new_ocsp_request): run in a
  separated process to continue on CentOS 5.6 i386.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-13 00:20:00 +00:00
akr fb2008a73a * test/lib/envutil.rb: Moved from test/ruby/.
* test/lib/find_executable.rb: Ditto.

* test/lib/memory_status.rb: Ditto.

* test/lib/test/unit.rb: require envutil.

* test/: Don't require envutil in test files.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-13 16:05:37 +00:00
akr 3864eb828b * test/openssl: Don't specify port number.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-13 12:46:58 +00:00
akr 1e502d2a10 * test/openssl/ssl_server.rb: Unused file removed.
It is not used since r16111, Ruby 1.9.1.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-13 12:28:12 +00:00
akr 5998b9d68f * test/openssl/utils.rb: The default of :ignore_listener_error is
changed to false.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48254 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-03 09:10:28 +00:00
akr e6aac32abf * test/openssl/test_ssl.rb: Don't ignore errors on listener threads,
as much as possible.

* test/openssl/test_ssl_session.rb: Ditto.

* test/openssl/test_partial_record_read.rb: Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-01 16:32:59 +00:00
akr a25e9259d5 ignore_ssl_accept_error option is changed to ignore_listener_error.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48231 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-01 15:56:29 +00:00
akr 88c37cdcc3 start_server refined.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-01 14:53:32 +00:00
akr 3ec72f078c * test/openssl/utils.rb (start_server): Don't close sockets before
threads finished.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-01 14:12:11 +00:00
akr d5802c512e * test/openssl/test_ssl_session.rb (test_ctx_client_session_cb): Don't
ignore errors of SSL accept.
  (test_ctx_server_session_cb): Ditto.

* test/openssl/utils.rb (server_loop): Add ignore_ssl_accept_error
  argument.
  (start_server): Refine threads waits.

* test/ruby/envutil.rb (assert_join_threads): Show a thread before
  backtrace.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-01 13:10:37 +00:00
akr a7c425cbf3 * test/openssl/utils.rb (start_server, server_loop): Use a
pipe to stop server instead of shutdown/close a listening socket.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-01 11:41:30 +00:00
headius 88326272bc * test/openssl/test_ssl.rb: Add certificate verification chain
test from JRuby community.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-31 20:49:51 +00:00
hsbt 51ee0a634e * test/openssl/test_pkey_rsa.rb (OpenSSL#test_sign_verify_memory_leak):
added timeout into testcase for low performance environment.
  [Bug #9984][ruby-core:63367]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47362 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-03 02:33:18 +00:00
hsbt 09ed8ca532 * test/openssl/test_ssl_session.rb: fix indent.
contributed from @spk. [fix GH-698]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-13 02:03:47 +00:00
naruse 97a4ecb0a3 add timeout
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-11 18:47:31 +00:00
nobu 981ab867f7 test_x509req.rb: fix for RHEL7
* test/openssl/test_x509req.rb (test_sign_and_verify_rsa_md5): fix
  exception to be rescued.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-23 05:37:09 +00:00
naruse 3b48a96c79 RHEL7 disables MD5
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-23 02:35:06 +00:00
naruse 594eee8543 split assertions into algorithms
CentOS 7 seems finish MD5 support
http://chkbuild005.hsbt.org/chkbuild/ruby-trunk/log/20140722T140010Z.fail.html.gz

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-22 16:02:05 +00:00
headius 3f103ad0e9 * test/openssl/test_509cert.rb: force sorted order for order-
sensitive test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-23 18:59:07 +00:00
usa 5d9eae4abb * test/openssl/test_ssl.rb (OpenSSL::TestSSL#test_verify_result):
shouldn't use same server for respective tests, because the 1st
  test sometimes kills the server main loop silently.
  [Bug #9881] [ruby-dev:48266]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46325 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-03 00:48:29 +00:00
akr 49aac86510 Suppress warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46297 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-01 15:13:59 +00:00
akr 68ac33a511 * ext/openssl/lib/openssl/ssl.rb (SSLServer#accept): Close a socket
if any exception occur. 



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46223 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-29 10:32:19 +00:00
akr 971df741b9 Close fds.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-28 15:06:39 +00:00
akr 02afafb42a * ext/openssl/ossl_ssl.c (ossl_ssl_close): Fix sync_close to work
when SSL is not started.
  This fix the fd leak by test_https_proxy_authentication in
  test/net/http/test_https_proxy.rb.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-28 09:09:26 +00:00
akr 9b612d382d * test/lib/minitest/unit.rb: Use Tempfile#close! instead of
Tempfile#unlink to close file descriptors.

* test/openssl/test_config.rb: Ditto.

* test/ruby/test_io.rb: Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-27 15:49:13 +00:00
kou bef1b7f1ca * test/openssl/test_pkcs7.rb: Fix inverted expected and actual values.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-27 11:57:41 +00:00
hsbt 6eb8acae90 * test/openssl/test_pair.rb: Modify TestSSL#test_read_and_write
to handle partial sysreads. [Bug #7398][ruby-core:49563]
* test/openssl/test_ssl.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46164 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-27 10:03:09 +00:00
svn 08e9b7d66c * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-27 09:48:30 +00:00
hsbt bab55ed3f5 * test/openssl/test_pkcs7.rb: Add tests for PKCS7#type= and add_data.
[Feature #7399][ruby-core:49565]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-27 09:48:27 +00:00
hsbt 64826fa792 * test/openssl/test_hmac.rb (test_binary_update): Added Test for
HMAC signing with UTF-8 String. [Bug #7512][ruby-core:50559]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-27 09:33:54 +00:00
akr 504453d929 * test/openssl: Join threads.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-25 05:22:49 +00:00
hsbt 894c04783b * test/openssl/test_partial_record_read.rb: Testing read_nonblock on
a partial TLS record results in IO::WaitReadable by @mohamedhafez.
  [fix GH-547]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-25 00:07:19 +00:00
akr b9f770ae8f refactored to test Socket and TCPSocket/TCPServer more consistently.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-07 23:21:10 +00:00
akr 2dbae9b1f1 * ext/openssl/lib/openssl/ssl.rb (OpenSSL::SSL::SSLServer#accept):
Consider Socket#accept as well as TCPServer#accept.
  Reported by Sam Stelfox.  [ruby-core:62064] [Bug #9750]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-07 12:48:27 +00:00
akr 1386a2303f refactoring to extract tcp_pair.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-07 12:22:02 +00:00
nobu a39b88d2fd ossl_pkey.c: fix memory leak
* ext/openssl/ossl_pkey.c (ossl_pkey_verify): as EVP_VerifyFinal()
  finalizes only a copy of the digest context, the context must be
  cleaned up after initialization by EVP_MD_CTX_cleanup() or a
  memory leak will occur.  [ruby-core:62038] [Bug #9743]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-16 00:51:18 +00:00
emboss 92a5ebb4b1 * test/openssl/test_ssl.rb: Reuse TLS default options from
OpenSSL::SSL::SSLContext::DEFAULT_PARAMS.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45280 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-07 03:15:39 +00:00
naruse 8d67a06b98 fix r45274; it change default but doesn't change tests [Bug #9424]
RUN TESTS BEFORE COMMIT!!!

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-06 16:42:27 +00:00
tenderlove e25f3587bd * ext/openssl/ossl_ssl.c: pass read_nonblock options to underlying IO
when SSL session has not been started.

* test/openssl/test_ssl.rb: test for change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-28 19:31:48 +00:00
nobu 0ede9926f7 openssl/digest.rb: get rid of deprecated class
* ext/openssl/lib/openssl/digest.rb (digest, hexdigest): create
  new instance and call on it directly, to get rid of deprecated
  class OpenSSL::Digest::Digest.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44115 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-10 07:16:01 +00:00
drbrain e45f56d5db * ext/openssl/lib/openssl/buffering.rb: Return ASCII-8BIT strings from
SSLSocket methods.  [ruby-trunk - Bug #9028]
* test/openssl/test_ssl.rb:  Test for the above.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-03 01:44:41 +00:00
akr e4f8f8907c * test/openssl/test_cipher.rb (test_aes_gcm_wrong_tag): Don't use
String#succ because it can make modified (wrong) auth_tag longer
  than 16 bytes.  The longer auth_tag makes that
  EVP_CIPHER_CTX_ctrl (and internally aes_gcm_ctrl) fail.
  [ruby-core:55143] [Bug #8439] reported by Vit Ondruch.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-14 10:58:15 +00:00
naruse 8db313151d wait until the shutdowning message reaches to the server
see #8831

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-04 18:46:16 +00:00
usa 6d18cc288a * test/openssl/test_pair.rb
(OpenSSL::TestPair#test_write_nonblock_no_exceptions): on some CIs
  such as Debian 6.0, Ubuntu 10.04, CentOS and vc10-x64 (maybe depend
  on OpenSSL version), writing to SSLSocket after SSL_ERROR_WANT_WRITE
  causes SSL_ERROR_SSL "bad write retry".


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-03 01:08:09 +00:00
tenderlove 988ca60565 * io.c (io_read_nonblock): support non-blocking reads without raising
exceptions. As in: `io.read_nonblock(size, exception: false)`
  [ruby-core:38666] [Feature #5138]
* ext/openssl/ossl_ssl.c (ossl_ssl_read_internal): ditto
* ext/stringio/stringio.c (strio_sysread): ditto
* io.c (rb_io_write_nonblock): support non-blocking writes without
  raising an exception.
* ext/openssl/ossl_ssl.c (ossl_ssl_write_internal): ditto
* test/openssl/test_pair.rb (class OpenSSL): tests
* test/ruby/test_io.rb (class TestIO): ditto
* test/socket/test_nonblock.rb (class TestSocketNonblock): ditto
* test/stringio/test_stringio.rb (class TestStringIO): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-26 22:41:44 +00:00
charliesome 885147037b * test/openssl/test_ssl.rb: Fix test for CVE-2013-4073.
Patch by Antonio Terceiro. [Bug #8750] [ruby-core:56437]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-07 21:00:34 +00:00
drbrain bdbef403a1 * ext/openssl/ossl_asn1.c (asn1time_to_time): Implement YYMMDDhhmmZ
format for ASN.1 UTCTime.  [ruby-trunk - Bug #8664]
* test/openssl/test_asn1.rb:  Test for the above.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-22 23:44:53 +00:00
emboss ed92ae818f * test/openssl/test_pkey_ec.rb: Skip tests for "Oakley" curves as
they are not suitable for ECDSA.
  [ruby-core:54881] [Bug #8384]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07 23:30:42 +00:00
emboss 0d58bb5598 * ext/openssl/ossl_pkey_ec.c: Ensure compatibility to builds of
OpenSSL with OPENSSL_NO_EC2M defined, but OPENSSL_NO_EC not
  defined.
* test/openssl/test_pkey_ec.rb: Iterate over built-in curves
  (and assert their non-emptiness!) instead of hard-coding them, as
  this may cause problems with respect to the different availability
  of individual curves in individual OpenSSL builds.
  [ruby-core:54881] [Bug #8384]

  Thanks to Vit Ondruch for providing the patch!


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-05 22:46:42 +00:00
emboss 880bc0e02d * test/openssl/test_x509crl.rb: Remove unused variable.
[ruby-core:53501] [Bug #8114]

  Thanks, Vipul Amler, for pointing this out!


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-05 22:16:09 +00:00
emboss a3a62f87e1 * lib/openssl/ssl.rb: Fix SSL client connection crash for SAN marked
critical.
  The patch for CVE-2013-4073 caused SSL crash when a SSL server returns
  the certificate that has critical SAN value.  X509 extension could
  include 2 or 3 elements in it:

  [id, criticality, octet_string] if critical,
  [id, octet_string] if not.

  Making sure to pick the last element of X509 extension and use it as
  SAN value.
  [ruby-core:55685] [Bug #8575]

  Thank you @nahi for providing the patch!


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-05 21:08:04 +00:00
nagachika bc47f294ee * ext/openssl/lib/openssl/ssl.rb (verify_certificate_identity): fix
hostname verification. Patched by nahi.

* test/openssl/test_ssl.rb (test_verify_certificate_identity): test for
  above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-27 11:09:19 +00:00
naruse 8b29525dad * ext/openssl/ossl_bn.c (ossl_bn_initialize): allow Fixnum and Bignum.
[ruby-core:53986] [Feature #8217]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-25 07:02:31 +00:00
akr 8f671120f1 * test/csv/test_features.rb, test/logger/test_logger.rb
test/mkmf/test_have_macro.rb, test/net/http/test_http.rb,
  test/openssl/test_config.rb, test/psych/test_encoding.rb,
  test/psych/test_exception.rb, test/psych/test_psych.rb,
  test/psych/test_tainted.rb, test/readline/test_readline.rb,
  test/rexml/test_contrib.rb, test/ruby/test_autoload.rb,
  test/ruby/test_beginendblock.rb, test/ruby/test_exception.rb,
  test/ruby/test_file.rb, test/ruby/test_io.rb,
  test/ruby/test_marshal.rb, test/ruby/test_process.rb,
  test/ruby/test_require.rb, test/ruby/test_rubyoptions.rb,
  test/syslog/test_syslog_logger.rb, test/webrick/test_httpauth.rb,
  test/zlib/test_zlib.rb: Use Tempfile.create.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-20 23:03:52 +00:00
naruse 053e85e2be * test/openssl/test_cipher.rb: Correct a typo
by jgls <joerg@joergleis.com>
  https://github.com/ruby/ruby/pull/291 fix GH-291

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-18 22:45:12 +00:00
emboss d6b1ab91dc * ext/openssl/ossl_ssl.c: Correct shutdown behavior w.r.t GC.
* test/openssl/test_ssl.rb: Add tests to verify correct behavior.  

[Bug #8240] Patch provided by Shugo Maeda. Thanks!


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-15 02:04:07 +00:00
headius 0626d9b91c Fix #6154 by introducing new EAGAIN/EWOULDBLOCK/EINPROGRESS
subclasses that include WaitReadable or WaitWritable rather than
extending them into the exception object each time.

* error.c: Capture EGAIN, EWOULDBLOCK, EINPROGRESS exceptions and
  export them for use in WaitReadable/Writable exceptions.
* io.c: Create versions of EAGAIN, EWOULDBLOCK, EINPROGRESS that
  include WaitReadable and WaitWritable. Add rb_readwrite_sys_fail
  for nonblocking failures using those exceptions. Use that
  function in io_getpartial and io_write_nonblock instead of
  rb_mod_sys_fail
* ext/openssl/ossl_ssl.c: Add new SSLError subclasses that include
  WaitReadable and WaitWritable. Use those classes for
  write_would_block and read_would_block instead of rb_mod_sys_fail.
* ext/socket/ancdata.c: Use rb_readwrite_sys_fail instead of
  rb_mod_sys_fail in bsock_sendmsg_internal and
  bsock_recvmsg_internal.
* ext/socket/init.c: Use rb_readwrite_sys_fail instead of
  rb_mod_sys_fail in rsock_s_recvfrom_nonblock and
  rsock_s_connect_nonblock.
* ext/socket/socket.c: Use rb_readwrite_sys_fail instead of
  rb_mod_sys_fail in sock_connect_nonblock.
* include/ruby/ruby.h: Export rb_readwrite_sys_fail for use instead
  of rb_mod_sys_fail. Introduce new constants RB_IO_WAIT_READABLE and
  RB_IO_WAIT_WRITABLE for first arg to rb_readwrite_sys_fail.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-08 19:58:55 +00:00
naruse 7b58445ebd * ext/openssl/ossl_bn.c (ossl_bn_initialize): fix can't create from bn.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-03 18:28:56 +00:00
naruse 0fb23a9449 fix typo: s/@ca_cert/@cacert/
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40048 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-02 02:02:33 +00:00
naruse 338456ad94 Suppress warning: OpenSSL::X509::StoreContext#cleanup is deprecated with no replacement
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-23 14:21:22 +00:00
emboss 4fce754f9b * ext/openssl/ossl.c: do not use FIPS_mode_set if not available.
* test/openssl/utils.rb: revise comment about setting FIPS mode to
  false.
* test/openssl/test_fips.rb: remove tests that cause errors on
  ruby-ci.
  [Feature #6946] [ruby-core:47345]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38491 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-20 07:00:11 +00:00
nobu d3d00ab8fe * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38489 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-20 06:18:26 +00:00
emboss 215b54806b * ext/openssl/ossl_cipher.c: add support for Authenticated Encryption
with Associated Data (AEAD) for OpenSSL versions that support the
  GCM encryption mode. It's the only mode supported for now by OpenSSL
  itself. Add Cipher#authenticated? to detect whether a chosen mode
  does support Authenticated Encryption.
* test/openssl/test_cipher.rb: add tests for Authenticated Encryption.
  [Feature #6980] [ruby-core:47426] Thank you, Stephen Touset for
  providing a patch!



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-20 06:03:03 +00:00
nobu 30fbc5591d * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-20 01:52:47 +00:00
emboss b28ac4039d * test/openssl/test_pkey_dh.rb: revert special treatment of
FIPS-capable installations since FIPS mode is now disabled for the
  tests.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-20 00:32:09 +00:00
emboss a3b753b282 * ext/openssl/ossl.c: add OpenSSL.fips_mode= to allow enabling FIPS
mode manually.
* test/openssl/utils.rb: turn off FIPS mode for tests. This prevents
  OpenSSL installations with FIPS mode enabled by default from raising
  FIPS-related errors during the tests.
* test/openssl/test_fips.rb: add tests for FIPS-capable OpenSSL
  installations.
  [Feature #6946] [ruby-core:47345]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-20 00:29:07 +00:00
emboss 831af844ef * test/openssl/test_ssl.rb: Use :TLSv1_2_client explicitly in
test_tls_v1_2 to prevent upstream bug.
  [Bug #7197] [ruby-dev:46240]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38436 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-18 02:32:28 +00:00
emboss e814e2ff3a * test/openssl/test_ssl.rb: Improve my grammar.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-18 02:04:52 +00:00
emboss 84f1dae9d6 * ext/openssl/lib/ssl.rb: Enable insertion of empty fragments as a
countermeasure for the BEAST attack by default. The default options
  of OpenSSL::SSL:SSLContext are now:
  OpenSSL::SSL::OP_ALL & ~OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS
  [Bug #5353] [ruby-core:39673]

* test/openssl/test_ssl.rb: Adapt tests to new SSLContext default.

* NEWS: Announce the new default.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-18 02:02:43 +00:00
nahi 361f6b2503 * test/openssl/test_cipher.rb (test_ctr_if_exists): add CTR mode test
if underlying OpenSSL supports it.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29 13:24:42 +00:00
naruse 58ef0f06c6 * ruby.c (load_file_internal): set default source encoding as
UTF-8 instead of US-ASCII. [ruby-core:46021] [Feature #6679]

* parse.y (parser_initialize): set default parser encoding as
  UTF-8 instead of US-ASCII.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 00:49:57 +00:00
nobu 974e3c9c5d * test/openssl/test_config.rb (OpenSSL#test_constants): skip only when
DEFAULT_CONFIG_FILE does not exist.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-06 14:26:29 +00:00
emboss 4bb125f91a * test/openssl/test_asn1_rb:
test/openssl/test_ssl_session.rb:
  test/openssl/test_x509name.rb:
  test/openssl/test_buffering.rb:
  test/openssl/test_x509cert.rb:
  test/openssl/test_ssl.rb: Refactor code that leads to warnings on
  Ruby CI.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-03 22:54:12 +00:00
emboss 78755b8d52 * test/openssl/utils.rb: Use DSS1 as DSA signature digest for all
OpenSSL versions < 1.0.0.
  [ruby-core:47405]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36891 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-03 22:09:33 +00:00
nobu a4ce3ab4fd remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-03 03:22:22 +00:00
emboss e29819df6e * ext/openssl/extconf.rb: Detect OpenSSL_FIPS macro
ext/openssl/ossl.c: Expose OpenSSL::OPENSSL_FIPS constant to
  indicate whether OpenSSL runs in FIPS mode.
  test/openssl/test_pkey_dh.rb: Generate 256 bit keys for
  non-FIPS installations to improve test performance (e.g. for
  rubyci).
  test/openssl/utils.rb: Replace DSS1 as certificate signature
  digest with SHA1 for FIPS installations when using DSA by
  introducing TestUtils::DSA_SIGNATURE_DIGEST.
  test/openssl/test_x509cert.rb: 
  test/openssl/test_x509crl.rb:
  test/openssl/test_x509req.rb: Use DSA_SIGNATURE_DIGEST
  NEWS: Introduce OpenSSL::OPENSSL_FIPS
  
  These changes allow running the OpenSSL tests in FIPS mode
  while keeping a high performance for non-FIPS installations.
  Introduction of OpenSSL::OPENSSL_FIPS allows for applications
  to react to special requirements when using OpenSSL in FIPS mode.
  [Feature #6946] [ruby-core:47345]
- Diese und die folgenden Zeilen werden ignoriert --

M    ext/openssl/extconf.rb
M    ext/openssl/ossl.c
M    NEWS
M    ChangeLog
M    test/openssl/utils.rb
M    test/openssl/test_x509crl.rb
M    test/openssl/test_x509req.rb
M    test/openssl/test_x509cert.rb
M    test/openssl/test_pkey_dh.rb


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-03 01:14:26 +00:00
emboss 5aa3caaa5d * test/openssl/utils.rb: Use a cached DH key instead of generating a
new one each time.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-02 12:50:02 +00:00
emboss 25e6db3e3c * ext/openssl/extconf.rb: Check existence of OPENSSL_NPN_NEGOTIATED.
ext/ossl_ssl.c: Support Next Protocol Negotiation. Protocols to be
  advertised by the server can be set in the SSLContext by using
  SSLContext#npn_protocols=, protocol selection on the client is
  supported by providing a selection callback with
  SSLContext#npn_select_cb. The protocol that was finally negotiated
  is available through SSL#npn_protocol.
  test/openssl/test_ssl.rb: Add tests for Next Protocol Negotiation.
  NEWS: add news about NPN support.
  [Feature #6503] [ruby-core:45272]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-31 09:47:36 +00:00
emboss 9871dd5783 * test/openssl/utils.rb
test/openssl/test_pair.rb
  test/openssl/test_pkey_dh.rb: Use 1024 bit DH parameters to satisfy
  OpenSSL FIPS requirements. Patch by Vit Ondruch.
  [Bug #6938] [ruby-core:47326]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-28 20:03:32 +00:00
nobu d059d718b5 remove trainling spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-21 04:50:18 +00:00
kosaki f207f7793d * test/openssl/test_config.rb (OpenSSL#test_constants): skip this
test if platform is Mac OS X or Windows. [Bug #6830]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-09 03:42:00 +00:00
emboss df05bd2c82 * ext/openssl/lib/openssl/digest.rb
test/openssl/test_digest.rb: Add Digest module function to OpenSSL
  module and test it. Patch provided by Eric Hodel.
  [ruby-core:46908][Feature #6819]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-02 01:58:49 +00:00
akr 4db96fe42c * test/openssl/test_config.rb: remove temporally files early.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36443 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-18 10:42:40 +00:00
emboss 3ffd8a918f * ext/openssl/ossl_pkey_ec.c
test/openssl/test_pkey_ec.rb: Add support for EC_POINT_mul.
  Patch provided by Sambasiva Suda. Thanks!
  [ruby-core:44408][ruby-trunk - Feature #6310]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-10 02:38:40 +00:00
emboss 5bd7899b98 * ext/openssl/ossl.c
ext/openssl/ossl_pkey_rsa.c
  ext/openssl/ossl_pkey_dsa.c
  ext/openssl/ossl_pkey_ec.c: Forbid export passwords that are less
  than four characters long, as OpenSSL itself does not allow this.
  Issue found by Eric Hodel.
* ext/openssl/ossl_pkey_ec.c: Add export as an alias of to_pem,
  following the PKey interface contract.
* test/openssl/test_pkey_dsa.rb
  test/openssl/test_pkey_rsa.rb
  test/openssl/test_pkey_ec.rb: Add tests that assert correct
  behaviour when dealing with passwords that are less than four
  characters long.
  [ruby-core: 42281][ruby-trunk - Bug #5951]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-10 01:23:21 +00:00
emboss 14ba7fab58 * ext/openssl/ossl_ssl.c: Introduce SSLContext#renegotiation_cb and
remove SSLContext#disable_client_renegotiation and related
  functionality introduced in r35797. The new callback approach
  gives clients maximum flexibility to decide on their own what to
  do on renegotiation attempts.
  Add documentation for SSL module and SSLError. 
* test/openssl/test_ssl.rb: Add a test for
  SSLContext#renegotiation_cb.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-09 16:44:12 +00:00
emboss 50ba64ab87 * ext/openssl/ossl_ssl.c: Allow disabling client-side renegotiation.
* test/openssl/test_ssl.rb: Simple tests for this.

  Client-side renegotiation is still considered problematic, even
  when used in the context of secure renegotiation (RI, RFC 5746).
  The changes allow users to either completely disable client
  renegotiation on the server, or to specify a maximum number of
  handshakes allowed in total. The number of total handshakes is
  counted in a callback set as SSL_set_info_callback. If the
  maximum number of handshakes is exceeded an error will be raised
  We do not support renegotiation in the OpenSSL extension, therefore
  this feature can only be tested externally.
  The feature is opt-in, the default setting will be to allow
  unlimited client renegotiation, as was the case before.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-26 00:56:33 +00:00
emboss 6f5582a2ae * test/openssl/test_ssl.rb: Clarify the intention of errors to be
expected. Two errors are possible when connection is refused due
  to a protocol version that was explicitly disallowed,
  OpenSSL::SSL::SSLError or Errno::ECONNRESET, depending on the
  OpenSSL version in use.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-25 14:44:15 +00:00
emboss 913827b6af * ext/openssl/ossl_ssl.c: Revert r35583
* test/openssl/test_ssl.rb: Handle ECONNRESET in code instead to avoid
the test failing in Ruby CI [1]
	
[1] http://u64.rubyci.org/~chkbuild/ruby-trunk/log/20120507T190102Z.log.html.gz#test-all


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-25 13:24:47 +00:00
naruse 2f6c48e53b OpenSSL 1.0.1 pre-beta disabled TLS v1.2 by default.
http://cvs.openssl.org/chngview?cn=21471

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-21 14:03:18 +00:00
nobu 8545d2f4b9 test_ssl.rb: test only if necessary option is available.
* test/openssl/test_ssl.rb (test_forbid_tls_v1_{1,2}_{for_client,from_server}):
  test only if necessary option is available.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-07 17:18:55 +00:00
emboss 5f7be3150f * ext/openssl/ossl_ssl.c: add support for option flags
OpenSSL::SSL::OP_NO_TLSv1_1
  OpenSSL::SSL::OP_NO_TLSv1_2
  to allow blocking specific TLS versions. Thanks to Justin Guyett for
  pointing this out to me.
* test/openssl/test_ssl.rb: add tests to assert correct behavior when
  blocking certain versions of TLS/SSL both on server and client side.
  Also refactored tests to reduce boilerplate code a little.
* test/openssl/utils.rb: rescue Errno::ECONNRESET for tests where
  client rejects the connection because a forbidden protocol version
  was used.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35567 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-07 11:57:01 +00:00
emboss 060184c347 * ext/openssl/ossl_ssl.c: support TLSv1.1 & TLSv1.1. Add
SSLContext#version to inspect the version that was negotiated for
  a given connection.
* ext/openssl/extconf.rb: detect TLS 1.1 & 1.2 support.
* test/openssl/test_ssl.rb: add tests for TLS 1.1 & 1.2 given they
  are supported by the native OpenSSL being used. 



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-06 22:26:08 +00:00
naruse 8c8796333a Wait until the callback is called with timeout.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-09 10:49:46 +00:00
emboss aad347f5ec * ext/openssl/ossl_pkcs7.c: fix crash when parsing garbage data.
* test/openssl/test_pkcs7.rb: assert correct behavior for it.
  Thanks to Matt Venables for reporting the issue.
  [ruby-core:43250][Bug #6134]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-29 01:27:17 +00:00
emboss 836af4e5dc * test/openssl/test_x509cert.rb: Exclude test that fails when issuing
a certificate with RSA signature and DSS1 digest for earlier
  OpenSSL versions when used in conjunction with OpenSSL 1.0.1.
  Thanks, Vit Ondruch, for reporting the issue.
  [ruby-core:42949][Bug #6089]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-29 00:32:09 +00:00
emboss 5bef1c9223 * ext/openssl/ossl_asn1.c: raise TypeError when trying to encode nil
values for Primitive instances. 
* test/openssl/test_asn1.rb: Assert consistent behavior when
  encoding nil values: Primitives raise TypeError, Constructives
  raise NoMethodError.
  Fixes [ruby-core:43009][Bug #6102]
-This line, and those below, will be ignored--

M    test/openssl/test_asn1.rb
M    ext/openssl/ossl_asn1.c
M    ChangeLog


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-28 22:53:18 +00:00
naruse 54b90b7be8 Fix condition.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-08 11:47:00 +00:00
naruse f75a30776c "street" for X509 Name is not supported before 0.9.8m.
It is added openssl/crypto/objects/obj_mac.h 1.83.
http://cvs.openssl.org/rlog?f=openssl/crypto/objects/obj_mac.h

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-08 09:49:36 +00:00
nahi 3ff2f9f3a3 * ext/openssl/ossl_ssl.c: Add SSL constants and allow to unset SSL
option to prevent BEAST attack. See [Bug #5353].

  In OpenSSL, OP_DONT_INSERT_EMPTY_FRAGMENTS is used to prevent
  TLS-CBC-IV vulunerability described at
  http://www.openssl.org/~bodo/tls-cbc.txt
  It's known issue of TLSv1/SSLv3 but it attracts lots of attention
  these days as BEAST attack. (CVE-2011-3389)

  Until now ossl sets OP_ALL at SSLContext allocation and call
  SSL_CTX_set_options at connection.  SSL_CTX_set_options updates the
  value by using |= so bits set by OP_ALL cannot be unset afterwards.

  This commit changes to call SSL_CTX_set_options only 1 time for each
  SSLContext. It sets the specified value if SSLContext#options= are
  called and sets OP_ALL if not.

  To help users to unset bits in OP_ALL, this commit also adds several
  constant to SSL such as
  OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS.  These constants were
  not exposed in Ruby because there's no way to unset bits in OP_ALL
  before.

  Following is an example to enable 0/n split for BEAST prevention.

    ctx.options = OP_ALL & ~OP_DONT_INSERT_EMPTY_FRAGMENTS

* test/openssl/test_ssl.rb: Test above option exists.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-08 05:27:14 +00:00
emboss 45706e70c9 * ext/openssl/ossl_x509name.c: Use the numerical representation of
unrecognized OIDs instead of the sn "UNDEF".

* test/openssl/test_x509name.rb: Add tests for the fixed behavior.

  Patch provided by Paul Kehrer, thanḱ you!
  [ruby-core:41769] [Feature #5787]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-08 04:19:33 +00:00
nahi be4f7bf512 * Make sure to clear $! when ignoring an exception
* ext/openssl/ossl.c (ossl_pem_passwd_cb0, ossl_verify_cb): 
  pem_passwd_cb and verify_cb ignores the exception raised in a 
  callback proc so it should clear $! for subsequent execution. 

  That's said, both subsequent processes for pem_passwd_cb and 
  verify_cb raises another exception before leaking $! to Ruby world.
  We cannot test this fix in Ruby land.

* test/openssl/test_pkey_rsa.rb
  (test_read_private_key_pem_pw_exception): Test for pem_passwd_cb + 
  exception.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-20 06:06:46 +00:00
emboss 0f59228a0b * test/openssl/test_engine.rb: remove side effect of generic engine
load by explicitly loading software-based "openssl" engine for
  all tests.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-26 14:04:52 +00:00
akr d7b7f56c8c * test/openssl/test_engine.rb: use IO#reopen to restore stderr.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-24 11:07:50 +00:00
emboss 452b74c106 * test/openssl/test_engine.rb: Suppress output from 'openssl'
engine's RC4 cipher.
  [Bug #5633] [ruby-core:41026]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-24 01:09:55 +00:00
emboss 600fcacc75 * test/openssl/test_engine.rb: add test for engine cipher. RC4 is used
because AES is not supported by the "openssl" engine currently.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-05 18:33:37 +00:00
nahi ab682d95e0 * ext/openssl/ossl_pkey_rsa.c (rsa_generate): [SECURITY] Set RSA
exponent value correctly.  Awful bug.  This bug caused exponent of
  generated key to be always '1'.  By default, and regardless of e
  given as a parameter.
    
  !!! Keys generated by this code (trunk after 2011-09-01) must be 
  re-generated !!! (ruby_1_9_3 is safe)
        
* test/openssl/test_pkey_rsa.rb: Add tests for default exponent and
  specifying exponent by a parameter.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33633 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-04 05:12:31 +00:00
emboss 3463615a69 * test/openssl/test_engine.rb: add first tests for builtin "openssl"
engine.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33632 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-04 00:33:11 +00:00
emboss 576454a432 * test/openssl/test_engine.rb: call Engine::cleanup on exit.
Patch provided by Yui Naruse, thanks!
  [Bug #5547] [ruby-core:40669]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-02 23:42:10 +00:00
akr df8126f9e3 * test/openssl/test_ssl.rb (test_multibyte_read_write): start server
for each length to avoid race condition.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-22 11:35:58 +00:00
emboss b878cfa971 * ext/openssl/ossl_ns_spki.c: Complete documentation.
* test/openssl/test_ns_spki.rb: Integrate SPKI#to_text.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-20 17:22:09 +00:00
emboss 359e7979d5 * test/openssl/test_pkcs5.rb: add RFC 6070 tests for PBKDF2 with
HMAC-SHA1


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-20 03:32:36 +00:00
emboss 65ca601ba6 * lib/openssl/buffering.rb: Force multi-byte strings to be treated as
binary data.
* test/openssl/test_ssl.rb: Add test for it.

Thanks to Niklas Baumstark for reporting the issue!

[Ruby 1.9 - Bug #5233] [ruby-core:39120]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-19 20:05:21 +00:00
nahi a31495b170 * test/openssl/test_ssl.rb: Move duplicated tests for SSL::Session to
test_ssl_session.rb


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-12 14:41:19 +00:00
emboss 8b7e10879e * ext/openssl/ossl_asn1.c: fix int_ossl_asn1_decode0_cons when being
fed arbitrary string values.
  Clearly distinguish between the cases "universal, infinite and
  not a SEQUENCE or SET" and "universal SEQUENCE or SET, possibly
  infinite". Raise error for universal tags that are not infinite.
* test/openssl/test_asn1.rb: add a test for this.

  Thanks to Hiroshi Yoshida for reporting this bug.
  [Bug #5363] [ruby-dev:44542]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-25 14:51:20 +00:00
emboss e2694c597d * test/openssl/test_ssl_session.rb: execute test_session_exts_read
only for OpenSSL versions >= 0.9.8k. Thanks, Eric Wong, for
  reporting this.
  [Bug #4961] [ruby-core:37726]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33315 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-23 04:51:19 +00:00
emboss e3af0655e2 * test/openssl/test_ssl_session.rb: ensure server calls callbacks in
test_ctx_server_session_cb. Thanks to Eric Wong for the patch.
  [Bug #5336] [ruby-core:39619]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-23 03:14:24 +00:00
naruse 3a902c4dbd Skip patented algorithms: IDEA and RC5 on NetBSD.
On NetBSD, if it uses patented algorithms without explicit option,
openssl will abort.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33301 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-20 07:18:37 +00:00
naruse c7b58831a3 Explicitly close the tcp connection.
Without this, the connection will be alive without GC after exit
the block and the test will fail as "TCPServer was closed and SSLServer
is still alive" on 64bit Unix: at least CentOS, Ubuntu, and FreeBSD.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-20 01:23:33 +00:00
naruse fbf4c1d277 OepnSSL supports TLS extension from 0.9.8f.
http://www.openssl.org/news/changelog.html
Reported by  Eric Wong. [ruby-core:39617] [Bug #4961]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-19 18:30:23 +00:00
drbrain 7c371d4658 * test/openssl/test_ssl.rb (class OpenSSL): Test
OpenSSL::SSL::SSLSocket#session and #session=.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-19 00:28:41 +00:00
nahi d3507e3ea6 * Release GVL while OpenSSL's public key generation.
t = Thread.new { print "."; sleep 0.1 }
    key = OpenSSL::PKey::RSA.new(2048)
    #=> Thread t works in parallel with public key generation if
        OS/machine allows it.

  This works with OpenSSL >= 0.9.8. From this version, it has new 
  public key generation function which allows us to interrupt the
  execution while pkey generation iterations.

* ext/openssl/extconf.rb: Check existence of OpenSSL's new public key
  generation function. (DH_generate_parameters_ex,
  DSA_generate_parameters_ex and RSA_generate_key_ex.

* ext/openssl/ossl_pkey.{h,c} (ossl_generate_cb_2,
  ossl_generate_cb_stop): Added new callback function for OpenSSL pkey
  generation which handles Thread interruption by Ruby.
  ossl_generate_cb_stop is the unblock function(ubf) for Ruby which
  sets a stop flag. New pkey generation callback ossl_generate_cb_2
  checks the stop flag at each iterations of OpenSSL and interrupts
  pkey generation when the flag is set.

* ext/openssl/ossl_pkey_dsa.c (dsa_generate): Call
  rb_thread_blocking_region with the above unblock function to release
  GVL while pkey generation.

* ext/openssl/ossl_pkey_rsa.c (rsa_generate): ditto.

* ext/openssl/ossl_pkey_dh.c (dh_generate): ditto.

* test/openssl/test_pkey_{dh,dsa,rsa}.rb: Test it.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-01 07:42:29 +00:00
emboss 1be5789eed * ext/openssl/ossl_ssl.c: Support disabling OpenSSL compression.
* test/openssl/test_ssl.rb: Add a test for it.
  Thanks to Eric Wong for the patch.
  [Ruby 1.9 - Feature #5183] [ruby-core:38911]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-15 01:10:26 +00:00
nahi e7e87b3c4e * ext/openssl/ossl_cipher.c (ossl_cipher_initialize): Avoid possible
SEGV from AES encryption/decryption. Processing data by
  Cipher#update without initializing key (meaningless usage of Cipher
  object since we don't offer a way to export a key) could cause SEGV.

  In OpenSSL, the EVP which has EVP_CIPH_RAND_KEY flag (such as DES3) 
  allows uninitialized key, but other EVPs (such as AES) does not
  allow it. Calling EVP_CipherUpdate() without initializing key causes
  SEGV so we set the data filled with "\0" as the key by default. See
  #2768.

* test/openssl/test_cipher.rb: test it.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-28 13:48:05 +00:00
emboss b9c485aa0d * test/openssl/test_pkcs12.rb: Add test and intermediate certificates.
[ Ruby 1.9 - Feature #3793 ] [ruby-core:32088]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-27 00:31:43 +00:00
emboss 84e835fe4a * ext/openssl/ossl_engine.c: Avoid double free of ENGINE reference.
* test/openssl/test_engine.rb: Add a test for it.
  Thanks to Ippei Obayashi for providing the patch.
  [ Ruby 1.9 - Bug #5062 ] [ruby-dev:44173]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-22 00:13:07 +00:00
emboss f8a538495e * test/openssl/test_ssl_session.rb: add PEM SSL session without TLS
extensions. Use this as the default for the tests to ensure
  compatibility with OpenSSL 0.9.7.
  [ Ruby 1.9 - Bug #4961 ] [ruby-core:37726]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-16 23:02:42 +00:00
nahi ab86f1cffb * ext/openssl/ossl.c (ossl_verify_cb): trap the exception from
verify callback of SSLContext and X509Store and make the 
  verification fail normally. Raising exception directly from callback
  causes orphan resouces in OpenSSL stack. Patched by Ippei Obayashi. 
  See #4445.

* test/openssl/test_ssl.rb
  (test_exception_in_verify_callback_is_ignored): test it.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-14 05:41:05 +00:00
emboss a5615faba1 * test/openssl/test_ocsp.rb
* test/openssl/test_x509_cert.rb: Perform SHA-256 tests only if
  supported by the available OpenSSL version. Versions < 0.9.8 don't
  support it. [ruby-core:37724]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-02 00:03:29 +00:00
emboss 1dcd4b325e * ext/openssl/ossl.c/.h: Added ossl_x509_name_sk2ary.
* ext/openssl/ossl.c: Replaced ossl_x509_ary2k by generic macro to
  simplify future conversions.
* ext/openssl/ossl_ssl.c: Implement SSLSocket#client_ca.
* test/openssl/test_ssl.rb: Add test for SSLSocket#client_ca.
  Thanks to Ippei Obayashi for providing the patch!
  [ Ruby 1.9 - Feature #4481 ] [ruby-core:35461]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-30 14:48:52 +00:00
nahi bf2e60cda7 * ext/openssl/ossl_x509name.c: Add X509::Name#hash_old as a wrapper
for X509_NAME_hash_old in OpenSSL 1.0.0. See #4805

* test/openssl/test_x509name.rb (test_hash): Make test pass with
  OpenSSL 1.0.0. 

* NEWS: Add it.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-23 13:51:55 +00:00
nahi 3e01a8d58e * test/openssl/test_ssl_session.rb: Test parameter bug fixed. 2**31 is not in
a signed long in 32bit long env.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-23 13:03:02 +00:00
nahi 544daf1f7a * ext/openssl/ossl_ssl_session.c (ossl_ssl_session_set_time): Check
argument type with NUM2LONG if the arg is not a Time object.
  See #4919.

* ext/openssl/ossl_ssl_session.c (ossl_ssl_session_set_timeout): Check
  type with NUM2LONG. Time as an arg is not allowed. See #4919.

* test/openssl/test_ssl_session.rb (test_session_time,
  test_session_timeout): Test it.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-23 10:36:09 +00:00
nahi dea3113ab3 * ext/openssl/ossl_ssl.c (ossl_sslctx_session_new_cb): Return 0 to
OpenSSL from the callback for SSL_CTX_sess_set_get_cb().
  Returning 0 means to OpenSSL that the the session is still valid
  (since we created Ruby Session object) and was not freed by us with
  SSL_SESSION_free(). Call SSLContext#remove_session(sess) in
  session_get_cb block if you don't want OpenSSL to cache the session
  internally.
  This potential issue was pointed by Ippei Obayashi. See #4416.

* test/openssl/test_ssl_session.rb (test_ctx_server_session_cb): Test
  it.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-22 13:39:56 +00:00
nahi d8af9c854d * ext/openssl/ossl_ssl.c (ossl_sslctx_session_remove_cb):
OpenSSL::SSL::SSLContext#session_remove_cb was broken. It wrongly 
  tried to call the session_*new*_cb callback.

* test/openssl/test_ssl_session.rb (class OpenSSL): Test it.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32200 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-22 09:24:31 +00:00
emboss 26cb830df9 * ext/openssl/ossl.h: Introduced OSSL_BIO_reset macro for PEM/DER
fallback scenarios.

* ext/openssl/ossl_pkey_dsa.c
* ext/openssl/ossl_x509req.c
* ext/openssl/ossl_pkey_rsa.c
* ext/openssl/ossl_pkey_ec.c
* ext/openssl/ossl_ssl_session.c
* ext/openssl/ossl_x509crl.c
* ext/openssl/ossl_pkey.c
* ext/openssl/ossl_pkey_dh.c
* ext/openssl/ossl_x509cert.c
* ext/openssl/ossl_pkcs7.c: Use OSSL_BIO_reset.

* ext/openssl/ossl_ssl.c
* ext/openssl/ossl_cipher.c
* ext/openssl/ossl_pkey_ec.c
* ext/openssl/ossl_pkcs12.c
* ext/openssl/ossl_ssl_session.c: Replace rb_raise occurences by
  ossl_raise. This automatically flushes OpenSSL's error queue.

* ext/openssl/ossl_pkcs7.c: Raise error if DER fallback for parsing
  fails.

* test/openssl/test_pkey_ec.rb
* test/openssl/test_pkey_dsa.rb
* test/openssl/test_pkey_rsa.rb: Add assertions that OpenSSL.errors is
  empty.

* test/openssl/test_pkey_rsa.rb: Remove initial OpenSSL.errors call in
  test_new.
  [ Ruby 1.9 - Bug #4885 ] [ruby-core:37134]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-22 08:41:08 +00:00
emboss 914a4a025a * test/openssl/test_buffering.rb
* test/openssl/test_pkcs12.rb: Inherit from Test::Unit::TestCase
  instead of Mintest::Unit::TestCase. [ruby-core:37275]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-22 05:48:44 +00:00
nahi bda678dc5b * ext/openssl/ossl_ssl_session.c (ossl_ssl_session_to_der):
OpenSSL::SSL::Session#to_der was broken. Fix buffer handling.

* test/openssl/test_ssl_session.rb (test_session): Test it.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-22 03:43:38 +00:00
nahi 02ab6d95be * test/openssl/test_ssl_session.rb: Split out SSL::Session related
tests from test_ssl.rb


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-22 03:40:08 +00:00
nahi 5e8aa0a1d2 * test/openssl/test_x509store.rb (test_set_errors): Redhat is
distributing a patched version of OpenSSL that allows multiple CRL 
  for a key (multi-crl.patch.) Make test pass on such env.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-21 16:33:06 +00:00
emboss 24acc9017a * test/openssl/test_config.rb: Commit missing file
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-15 16:04:32 +00:00
naruse bfa6c6b41b Clear error messages before process and get errors. [ruby-dev:43791] [Bug #4879]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-14 01:38:56 +00:00
emboss 839614309d * test/openssl/test_ec.rb
test/openssl/test_pkey_ec.rb: merge both files into test_pkey_ec.rb.
  Removed redundant group instantiation from PKey tests.
* test/openssl/utils.rb: only create TEST_PKEY_EC_P256V1 if EC is
  defined.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-13 11:56:04 +00:00
emboss 56aca9fc00 * test/openssl/digest.rb: remove MDC2 from test, it is not available
by default in an OpenSSL installation.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-13 11:32:43 +00:00
emboss 1c629eff85 * ext/openssl/ossl_digest.c: fix error for digests that have no oid
(e.g. DSS1).
* test/openssl/test_digest.c: add tests for this.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-13 04:09:04 +00:00
emboss 4247bfd60a * ext/openssl/ossl_digest.c: allow Digests to be created by sn, ln or
oid.
* test/openssl/test_digest.rb: add tests for this.
  [Ruby 1.9 - Feature #4412] [ruby-core:35319]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-13 02:37:35 +00:00
emboss a27b63d3fc * ext/openssl/pkey_dh.c: corrected documentation.
* test/openssl/utils.rb: add test key for DH.
* test/openssl/test_pkey_dh.rb: add tests.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-13 01:58:09 +00:00