Commit graph

21 commits

Author SHA1 Message Date
Kazuki Yamaguchi
495b1cad04 [ruby/openssl] ts: use TS_VERIFY_CTX_set0_{store,certs}() on OpenSSL 3.4
In OpenSSL 3.4, TS_VERIFY_CTX_set_certs() and TS_VERIFY_CTX_set_store()
are deprecated in favor of the new functions with "set0" in the names.

The new functions have a slightly different behavior. They will free the
previous value automatically. Increment the reference counter of
X509_STORE before setting it to TS_VERIFY_CTX, and do not try to
manually unset it.

We avoided doing this to work around a bug that was present in older
versions of OpenSSL, which has now been fixed in OpenSSL 1.0.2 by commit
bff9ce4db3.

ce37f7d93a
2025-01-23 01:45:52 +09:00
Theo Buehler
72fdba156d [ruby/openssl] Use X509_ALGOR_get0() accessor for X509_ALGOR
While the struct is currently still public in OpenSSL, there has been
an accessor since OpenSSL 0.9.8h. It would be nice if this accessor
could be used so that the struct can be made opaque at some point in
the future.

812aeab2f5
2025-01-21 18:17:06 +00:00
Kazuki Yamaguchi
441862dc9f [ruby/openssl] Require OpenSSL 1.1.0 or later
Drop support for OpenSSL 1.0.2. It has reached upstream EOL in 2019-12.

Most distributions that shipped with OpenSSL 1.0.2 have also reached
EOL, or provide a newer version in the package repository:

 - RHEL 7 (EOL 2024-06)
 - Ubuntu 16.04 LTS (EOL 2021-04)
 - Amazon Linux 2 (EOL 2026-06, but OpenSSL 1.1.1 can be installed via
   the openssl11{,-devel} package)

38ec6fd50e
2025-01-20 17:12:57 +00:00
Kazuki Yamaguchi
09d516b62e [ruby/openssl] Call Init_ossl_*() functions in alphabetical order
It was originally sorted in alphabetical order, but it has been broken
over time. Let's fix it.

974c67f38f
2024-12-07 07:55:47 +00:00
Kazuki Yamaguchi
cbe7bfd9a8 [ruby/openssl] ts: fix exception class raised when getting an OID name
get_asn1obj() is used by several methods in OpenSSL::Timestamp to get
the string representation of an OID. On an error, such as memory
allocation failure, it can raise OpenSSL::X509::AttributeError. It
should be OpenSSL::Timestamp::TimestampError instead.

a424aad1df
2024-12-07 07:55:46 +00:00
Kazuki Yamaguchi
f8e9302e66 [ruby/openssl] ts: avoid using OpenSSL::PKCS7's internals
Internals of OpenSSL::PKCS7 should be kept within ossl_pkcs7.c.

Add a new ossl_pkcs7_new() function for duplicating and wrapping an
OpenSSL PKCS7 object in OpenSSL::PKCS7. This follows the convention
used by other ossl_*_new() functions.

b5f79f771e
2024-12-07 07:55:46 +00:00
Kazuki Yamaguchi
69c0b1438a [ruby/openssl] Fix references to the license text
Update the references to the file "LICENCE" with "COPYING".

The file LICENCE doesn't exist in ruby/ruby nor ruby/openssl. This has
been always the case since OpenSSL for Ruby 2 was merged to the ruby
tree as a standard library in 2003.

In OpenSSL for Ruby 2's CVS repository[1], the LICENCE file contained
an old version of the Ruby License, identical to the COPYING file that
was in Ruby's tree at that time (r4128[2]).

[1] http://cvs.savannah.gnu.org/viewvc/rubypki/ossl2/LICENCE?revision=1.1.1.1&view=markup
[2] 231247c010/COPYING

5bccf07d04
2024-06-08 10:59:17 +00:00
Samuel Giddins
841b45a442 [ruby/openssl] Add to_text for PKCS7 and Timestamp::Response
71cd1e3f5c
2024-05-08 09:39:13 +00:00
Jean Boussier
1965c09ee5 [ruby/openssl] Implement Write Barrier for all OpenSSL types
The vast majority have no reference so it's just a matter of setting the flags.

For the couple exception, they have very little references so it's
easy.

2c7c6de69e
2023-06-19 01:57:09 +09:00
Kazuki Yamaguchi
19ef7082ba [ruby/openssl] ts: use TS_VERIFY_CTX_set_certs instead of TS_VERIFY_CTS_set_certs
OpenSSL 3.0 fixed the typo in the function name and replaced the
current 'CTS' version with a macro.

2be6779b08
2021-10-25 00:40:43 +09:00
Nobuhiro IMAI
f88401f38e [ruby/openssl] fix segv in Timestamp::{Request,Response,TokenInfo}.new
prevent `ossl_ts_*_free()` from calling when `d2i_TS_*_bio()` failed.

b29e215786
2021-10-16 18:34:35 +09:00
David Carlier
6dcc74155f [ruby/openssl] ts: libressl build fix warning
TS_time_cb on libressl expects an long long/time_t 64 bits long instead.

4c99f577b2
2021-10-16 18:34:35 +09:00
Nobuyoshi Nakada
6920f3dc96 [ruby/openssl] Suppress cast-function-type warnings
0f91e2a6ee
2021-09-12 22:49:05 +09:00
Nobuyoshi Nakada
598d66f6b2 [ruby/openssl] Separate formatting from ossl_make_error
Just append OpenSSL error reason to the given message string
object, which would be alreadly formatted.
Suppress -Wformat-security warning in `ossl_tsfac_create_ts`.

11b1d8a6b8
2021-09-12 22:49:03 +09:00
Kazuki Yamaguchi
cd002305f0 [ruby/openssl] require OpenSSL >= 1.0.2 and LibreSSL >= 3.1
Clean up old version guards in preparation for the upcoming OpenSSL 3.0
support.

OpenSSL 1.0.1 reached its EOL on 2016-12-31. At that time, we decided
to keep 1.0.1 support because many major Linux distributions were still
shipped with 1.0.1. Now, nearly 4 years later, most Linux distributions
are reaching their EOL and it should be safe to assume nobody uses them
anymore. Major ones that were using 1.0.1:

 - Ubuntu 14.04 is EOL since 2019-04-30
 - RHEL 6 will reach EOL on 2020-11-30

LibreSSL 3.0 and older versions are no longer supported by the LibreSSL
team as of October 2020.

Note that OpenSSL 1.0.2 also reached EOL on 2019-12-31 and 1.1.0 also
did on 2018-08-31.

c055938f4b
2021-07-18 17:44:41 +09:00
Nobuyoshi Nakada
1ad2224773 [ruby/openssl] Fixed the results of OpenSSL::Timestamp::Response#failure_info
Made stored values `Symbol`s instead of `ID`s.

Fixes https://bugs.ruby-lang.org/issues/17625

Co-Authored-By: xtkoba (Tee KOBAYASHI) <xtkoba+ruby@gmail.com>

f2d004679a
2021-03-16 19:37:06 +09:00
Kazuki Yamaguchi
15863069c9 [ruby/openssl] digest, hmac, ts, x509: use IO.binread in examples where appropriate
IO.read may mangle line separator, which will corrupt binary data
including DER-encoded X.509 certificates and such.

Fixes: https://github.com/ruby/openssl/issues/243

93213b2730
2021-03-16 19:16:11 +09:00
Nobuyoshi Nakada
5a77e90fe8
Use rb_intern_const instead of rb_intern in Init functions
```
find . -name \*.o -exec nm {} + |&
sed '/Init_.*\.rbimpl_id/!d;s/^.* b //;s/\.[1-9][0-9]*$//;s/\.rbimpl_id$//' |
uniq
```
should be empty.
2020-10-21 12:46:53 +09:00
Bart de Water
0b2c70eaa1 [ruby/openssl] Look up digest by name instead of constant
b28fb2f05c
2020-05-13 15:47:51 +09:00
Kazuki Yamaguchi
99b191d83f [ruby/openssl] ts: simplify OpenSSL::Timestamp::Request#algorithm
Stop the special treatment of invalid hashAlgorithm of the message
imprint. Those invalid values can only appear after the object is
instantiated, before the user sets an actual message digest algorithm.

OpenSSL::Timestamp::TokenInfo#algorithm already does the same.

Also, remove the test case "test_create_request" since it does not make
much sense. Those fields are to be set by the user after creation of
the object and checking the initial value is pointless.

Fixes: https://github.com/ruby/openssl/issues/335

890a6476fa
2020-02-17 20:50:47 +09:00
Hiroshi SHIBATA
b99775b163
Import openssl-2.2.0 (#2693)
Import the master branch of ruby/openssl for preparing to release openssl-2.2.0
2020-02-16 15:21:29 +09:00