aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* test: run test cases under GC.stress if OSSL_GC_STRESS is specifiedtopic/under-gc-stressKazuki Yamaguchi2016-12-051-0/+9
| | | | | This would have caught some of GC issues like one reported at [ruby/openssl#87].
* test/test_pair: make TestPairM#test_write_nonblock_retry fasterKazuki Yamaguchi2016-12-051-1/+1
| | | | | | | Write 4099-bytes blocks instead of 11-bytes blocks to run it faster. The buffer may be as large as megabytes and it takes too much time to fill up, especially under GC.stress. I didn't measured but it didn't finish in an hour.
* test: call super from each test case's 'setup' methodKazuki Yamaguchi2016-12-0514-0/+14
| | | | | | Just like we already do for 'teardown' method, though we don't have OpenSSL::TestCase#setup yet. This will be useful when we want to inject GC.stress = true.
* ssl: prevent encoded NPN advertised protocol list from being GCedKazuki Yamaguchi2016-12-051-1/+4
| | | | | | | | | SSLContext#setup encodes the protocol list set in @npn_protocols into a String. The String is passed to SSL_CTX_set_next_protos_advertised_cb() and OpenSSL invokes the callback function with the String. However since Ruby's GC can't find the reference to the String from the inside of OpenSSL, it can be free'd before the callback is invoked. So store the String in an instance variable to prevent this.
* bn: keep reference to temporary OpenSSL::BN object created by GetBNPtr()Kazuki Yamaguchi2016-12-043-19/+31
| | | | | | | | | GetBNPtr() accepts both OpenSSL::BN and Ruby integers. In the latter case, it creates a temporary OpenSSL::BN internally. The OpenSSL::BN object immediately disappears from the stack and is not protected from GC. Fixes: https://github.com/ruby/openssl/issues/87
* pkey: check existence of EVP_PKEY_get0()Kazuki Yamaguchi2016-12-012-0/+5
| | | | | EVP_PKEY_get0() did not exist in early OpenSSL 0.9.8 series. So define ourselves if needed.
* test/test_cipher: fix test with OpenSSL 1.0.1 before 1.0.1dKazuki Yamaguchi2016-12-011-8/+8
| | | | | | | | | Set the authentication tag before the AAD when decrypting. Before OpenSSL commit 96f7fafa2431 ("Don't require tag before ciphertext in AESGCM mode", 2012-10-16, at OpenSSL_1_0_1-stable branch, included in OpenSSL 1.0.1d), the authentication tag must be set before any calls of EVP_CipherUpdate().
* Ruby/OpenSSL 2.0.0v2.0.0Kazuki Yamaguchi2016-11-301-1/+1
|
* Copy History.md to the Ruby treeKazuki Yamaguchi2016-11-301-0/+1
| | | | sync:to_ruby Rake task now copies History.md to ext/openssl/History.md.
* ssl: follow-up for the workaround for OpenSSL 1.1.0c's SSL_read()Kazuki Yamaguchi2016-11-301-7/+7
| | | | | | | | Remove the comment added by commit 072d53ecf984 ("ssl: workaround for new behavior of SSL_read() in OpenSSL >= 1.1.0c"). The breaking change in OpenSSL 1.1.0c has been reverted in the 1.1.0 branch. However, for the sake of safety, ensure that we never call rb_sys_fail() with errno == 0. So there is no change in the actual code.
* Merge changes from Ruby trunk r56492..r56927Kazuki Yamaguchi2016-11-303-6/+6
|\ | | | | | | | | | | | | | | * ruby-trunk r56492..r56927: (2 commits) (r56927) parse.y: ambiguous parentheses (r56578) openssl/ut_eof.rb: rename TestEOF Sync-with-trunk: r56927
| * parse.y: ambiguous parenthesesnobu2016-11-301-1/+1
| | | | | | | | | | | | | | * parse.y (parser_yylex): warn ambiguous parentheses after a space in method definitions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| * openssl/ut_eof.rb: rename TestEOFnobu2016-11-302-5/+5
| | | | | | | | | | | | | | * test/openssl/ut_eof.rb (OpenSSL::TestEOF): move TestEOF module under OpenSSL to get rid of conflict with test/ruby/ut_eof.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* | test: fix fragile test casesKazuki Yamaguchi2016-11-309-128/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix the fragile test cases that are sensitive to the difference between Time.now.to_i and time(2). When issuing test certificates, we are typically setting the current time fetched by Time.now to the notBefore field. Time.now uses clock_gettime(2) with CLOCK_REALTIME. On the other hand, OpenSSL uses time(2) in its certificate verification code. On Linux/x86-64, time(2) is implemented not to return the adjusted 'current time' like Time.now, but to return the wall clock seconds at the last tick. This results in that time(2) called later may return an earlier time, causing the certificate verification to fail with 'certificate is not yet valid' error. So, create test certificates with notBefore<Time.now to avoid this. Since it's awful to do "Time.now - 1" everywhere, make the notBefore and notAfter fields optional with defaults with margin.
* | Merge branch 'topic/ssl-make-sslctx-freeze-alias-of-setup'Kazuki Yamaguchi2016-11-292-0/+13
|\ \ | | | | | | | | | | | | * topic/ssl-make-sslctx-freeze-alias-of-setup: ssl: make OpenSSL::SSL::SSLContext#freeze an alias of #setup
| * | ssl: make OpenSSL::SSL::SSLContext#freeze an alias of #setuptopic/ssl-make-sslctx-freeze-alias-of-setupKazuki Yamaguchi2016-11-292-0/+13
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SSLSocket#setup uses the frozen state as "SSL_CTX is already set up". If an user manually freeze the context, it misunderstands as if #setup is already called, leading to unexpected behaviors because parameters the user set won't be actually set to the underlying SSL_CTX and thus ignored. Ideally, #setup should go and be replaced with setters. But we don't do this now because it is not that simple: some of them would produce new ordering issues, e.g. 'ca_file' property which loads a file into SSL_CTX::cert_store and 'cert_store' which replaces SSL_CTX::cert_store would conflict. Fixing this properly would require deprecating 'ca_file' first. So, let's take the second best way: make it "just work" instead of break silently. Fixes: https://github.com/ruby/openssl/issues/85
* | ssl: fix possible exception from non-protected codeKazuki Yamaguchi2016-11-281-42/+66
| | | | | | | | | | | | | | | | | | | | | | rb_ary_new_from_args() is called from non-protected callback function which will be directly called from OpenSSL. It may raise NoMemoryError and may corrupt the internal state of SSL object. So, avoid creating Array here and pass raw values to the protected function instead. The same change has been applied to ALPN/NPN selection callbacks in 3a926047a729 ("ssl: catch exceptions raised in ALPN/NPN callbacks", 2016-08-30).
* | ssl: inline ossl_ssl_shutdown() into ossl_ssl_stop()Kazuki Yamaguchi2016-11-281-20/+15
| | | | | | | | | | | | | | | | We call SSL_shutdown() four times at most meaninglessly. Since the underlying socket is in non-blocking mode, if the first call failed because the underlying socket is not write/readable, the subsequent calls would just fail with the same error. Just call once, and give up if it fails.
* | engine: undef alloc functionKazuki Yamaguchi2016-11-162-25/+1
| | | | | | | | | | | | This prevents users from allocating OpenSSL::Engine instance using OpenSSL::Engine.allocate. Undef'ing alloc function also allows us to remove explicit undef of OpenSSL::Engine.new and #initialize_copy.
* | asn1: fix possible segfault in OpenSSL::ASN1::Constructive#eachKazuki Yamaguchi2016-11-161-2/+6
| | | | | | | | | | Don't blindy assume that the value which can be modified from Ruby code is always an Array, and just call its #each method.
* | digest: don't allocate EVP_MD_CTX at OpenSSL::Digest object allocationKazuki Yamaguchi2016-11-151-15/+22
| | | | | | | | | | | | Delay allocation of EVP_MD_CTX until #initialize or #initialize_copy is called. This fixes segfault that can occur if OpenSSL::Digest#name is called before the actual initialization.
* | ssl: workaround for new behavior of SSL_read() in OpenSSL >= 1.1.0cKazuki Yamaguchi2016-11-131-4/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | Commit 4880672a9b41 of OpenSSL[1] (which then was backported to 1.1.0 branch at 122580ef71e4) changed the bahavior of SSL_read(): it now returns -1 in the case the underlying BIO reaches EOF unexpectedly. This means, it is possible that rb_sys_fail() is called with errno == 0, resulting in [BUG]. So, as a workaround, let's distinguish IO error from the underlying BIO and EOF in violation of SSL/TLS protocol with the value of errno. [1] https://git.openssl.org/?p=openssl.git;a=commit;h=4880672a9b41a09a0984b55e219f02a2de7ab75e
* | Merge branch 'topic/asn1-fix-oob-read-constructed'Kazuki Yamaguchi2016-11-072-7/+29
|\ \ | | | | | | | | | | | | * topic/asn1-fix-oob-read-constructed: asn1: fix out-of-bounds read in decoding constructed objects
| * | asn1: fix out-of-bounds read in decoding constructed objectstopic/asn1-fix-oob-read-constructedKazuki Yamaguchi2016-09-282-7/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | OpenSSL::ASN1.{decode,decode_all,traverse} have a bug of out-of-bounds read. int_ossl_asn1_decode0_cons() does not give the correct available length to ossl_asn1_decode() when decoding the inner components of a constructed object. This can cause out-of-bounds read if a crafted input given. Reference: https://hackerone.com/reports/170316
* | | Merge pull request #84 from tarcieri/for-rubyKazuki Yamaguchi2016-11-071-1/+1
|\ \ \ | | | | | | | | Add "for Ruby" to the README title
| * | | Add "for Ruby" to the README titleTony Arcieri2016-11-061-1/+1
|/ / / | | | | | | | | | It's not immediately clear from the README exactly what this project is
* | | Merge branch 'topic/rake-install-dependencies'Kazuki Yamaguchi2016-11-064-16/+24
|\ \ \ | | | | | | | | | | | | | | | | * topic/rake-install-dependencies: Add install_dependencies rake task that installs testing dependencies
| * | | Add install_dependencies rake task that installs testing dependenciestopic/rake-install-dependenciesKazuki Yamaguchi2016-11-064-16/+24
|/ / / | | | | | | | | | | | | | | | | | | | | | Parse the dependency gems from openssl.gemspec and install them. This is extracted from tool/ruby-openssl-docker/init.sh. .travis.yml, appveyor.yml and CONTRIBUTING.md are also updated to use the new task.
* | | Merge pull request #82 from ruby/badgeKazuki Yamaguchi2016-11-051-0/+1
|\ \ \ | | | | | | | | Appveyor status badge
| * | | added appveyor status badgeSHIBATA Hiroshi2016-11-031-0/+1
|/ / /
* | / Relax development dependencyKazuki Yamaguchi2016-11-031-3/+3
| |/ |/|
* | Merge changes from Ruby trunk r56225..r56492Kazuki Yamaguchi2016-10-281-1/+1
|\ \ | | | | | | | | | | | | | | | | | | * ruby-trunk r56225..r56492: (1 commits) (r56492) [DOC] replace Fixnum with Integer [ci skip] Sync-with-trunk: r56492
| * | [DOC] replace Fixnum with Integer [ci skip]nobu2016-10-281-1/+1
| | | | | | | | | | | | | | | | | | * numeric.c: [DOC] update document for Integer class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* | | Move verify_callback stuff to ossl_x509store.cKazuki Yamaguchi2016-10-284-103/+89
| | | | | | | | | | | | | | | Accordingly, unused functions ossl_x509stctx_new() and ossl_x509stctx_clear_ptr() are now removed.
* | | Don't include openssl/e_os2.hKazuki Yamaguchi2016-10-281-15/+1
| | | | | | | | | | | | | | | It defines the platform specific macros. But it should be included from other OpenSSL headers.
* | | asn1: don't include sys/time.hKazuki Yamaguchi2016-10-281-9/+0
| | | | | | | | | | | | | | | And also remove alternative declaration of struct timeval. We don't actually use struct timeval nor struct timespec anymore since r4660.
* | | Don't check for assert.hKazuki Yamaguchi2016-10-282-7/+1
| | | | | | | | | | | | | | | The Ruby core code uses assert.h without a guard. So, we can assume it is always available.
* | | Don't include unistd.hKazuki Yamaguchi2016-10-282-7/+0
| | | | | | | | | | | | | | | | | | | | | As the comment suggests, ossl_ssl.c used to call read() and write() in the past. However r6806 replaced them with method calls for the underlying IO object. Anyway, unistd.h will be included by Ruby's header files if available.
* | | Always include openssl/crypto.hKazuki Yamaguchi2016-10-282-7/+1
| | | | | | | | | | | | It should be usable regardless of the platform.
* | | Merge pull request #80 from ruby/appveyorSHIBATA Hiroshi2016-10-281-0/+16
|\ \ \ | | | | | | | | Enabled appveyor for Windows build
| * | | update openssl-1.0.1mSHIBATA Hiroshi2016-10-271-3/+3
| | | |
| * | | Enabled to build mingw environment on Windows.SHIBATA Hiroshi2016-10-271-0/+16
|/ / / | | | | | | | | | | | | | | | * To use oneclick-rubyinstaller for configuration. * To use openssl binary provided onclick-rubyinstaller * https://github.com/oneclick/knapsack-recipes/tree/master/openssl
* | | Avoid using ERR_get_error()Kazuki Yamaguchi2016-10-272-2/+2
| | | | | | | | | | | | | | | | | | | | | Use ERR_peek_error() which does not remove the fetched error from the queue instead, then clear the queue explicitly with the dedicated function ossl_clear_error(). OpenSSL may put multiple error items to the queue in one function call.
* | | ssl: avoid using ossl_exc_new()Kazuki Yamaguchi2016-10-273-20/+4
| | | | | | | | | | | | | | | | | | | | | Avoid using ossl_exc_new() and rb_exc_raise() but just use ossl_raise(). This simplifies the code with the exactly same effect. ossl_exc_new() is now removed as it is no longer used anywhere.
* | | Remove unnecessary #undef RFILEKazuki Yamaguchi2016-10-271-6/+0
| | | | | | | | | | | | | | | | | | The macro RFILE is defined in e_os.h, that is no longer an exported header in OpenSSL >= 0.9.7. Since OpenSSL < 0.9.8 is not supported, we can safely remove this.
* | | Remove unnecessary compat macro for old versions of RubyKazuki Yamaguchi2016-10-271-9/+0
| | | | | | | | | | | | | | | Remove unnecessary macros defined for compatibility with Ruby < 1.9. We won't support Ruby versions before 2.3.
* | | Don't check for wsock32 and gdi32 on MinGW environmentKazuki Yamaguchi2016-10-271-5/+0
| | |
* | | test/test_pair: revert workaround added by r42790Kazuki Yamaguchi2016-10-241-12/+6
| | | | | | | | | | | | | | | | | | | | | It was added as a workaround for "bad write retry" error that occurs when SSLSocket#write_nonblock is retried with a different String. This is now fixed by r54466 ("openssl: accept moving write buffer for write_nonblock", 2016-03-31).
* | | openssl: document `exception: false' for *_nonblockEric Wong2016-10-241-0/+8
| | | | | | | | | | | | | | | | | | * lib/openssl/buffering.rb (read_nonblock, write_nonblock): document `exception: false' [ruby-core:73882] [Feature #12085]
* | | Fix possible RangeError in ossl_pem_passwd_cb()Kazuki Yamaguchi2016-10-221-4/+5
| | | | | | | | | | | | | | | | | | | | | Avoid RSTRING_LENINT() which may raise RangeError. Since ossl_pem_passwd_cb() is supposed to be called from OpenSSL as a callback, we must not do longjmp from it.