Commit graph

648 commits

Author SHA1 Message Date
Samuel Chiang
0b9644c252 [ruby/openssl] AWS-LC has support for parsing ber constructed strings now
cdfc08db50
2025-05-15 16:40:42 +00:00
Kazuki Yamaguchi
93afcfcde3 [ruby/openssl] asn1: check for missing EOC in indefinite length encoding
EOC octets are required at the end of contents of a constructed encoding
that uses the indefinite length form. This cannot be assumed from the
end of the input. Raise an exception when necessary.

bc20c13a7c
2025-04-20 07:41:15 +00:00
Kazuki Yamaguchi
0a8a641d0a [ruby/openssl] ssl: fix SSLSocket#syswrite with String-convertible objects
Correctly pass the new object assigned by StringValue() to
ossl_ssl_write_internal_safe().

This is a follow-up to commit 0d8c17aa85 (Reduce
OpenSSL::Buffering#do_write overhead, 2024-12-21).

3ff096196a
2025-04-16 15:16:50 +00:00
Jun Aruga
d5f94941d8 [ruby/openssl] Fix the tests using SHA-1 Probabilistic Signature Scheme (PSS) parameters.
Fedora OpenSSL 3.5 on rawhide stopped accepting SHA-1 PSS[1] parameters.
This is different from the SHA-1 signatures which Fedora OpenSSL stopped
accepting since Fedora 41.[2]

This commit fixes the following test failures related to the SHA-1 PSS
parameters with Fedora OpenSSL 3.5.
Note these failures are the downstream Fedora OpenSSL RPM specific. The tests
pass without this commit with the upstream OpenSSL 3.5.

```
$ rpm -q openssl-libs openssl-devel
openssl-libs-3.5.0-2.fc43.x86_64
openssl-devel-3.5.0-2.fc43.x86_64

$ bundle exec rake test
...
E
===============================================================================================
Error: test_sign_verify_options(OpenSSL::TestPKeyRSA): OpenSSL::PKey::PKeyError: EVP_PKEY_CTX_ctrl_str(ctx, "rsa_mgf1_md", "SHA1"): digest not allowed (digest=SHA1)
/mnt/git/ruby/openssl/test/openssl/test_pkey_rsa.rb:113:in 'Hash#each'
/mnt/git/ruby/openssl/test/openssl/test_pkey_rsa.rb:113:in 'OpenSSL::PKey::PKey#sign'
/mnt/git/ruby/openssl/test/openssl/test_pkey_rsa.rb:113:in 'OpenSSL::TestPKeyRSA#test_sign_verify_options'
     110:       "rsa_pss_saltlen" => 20,
     111:       "rsa_mgf1_md" => "SHA1"
     112:     }
  => 113:     sig_pss = key.sign("SHA256", data, pssopts)
     114:     assert_equal 256, sig_pss.bytesize
     115:     assert_equal true, key.verify("SHA256", sig_pss, data, pssopts)
     116:     assert_equal true, key.verify_pss("SHA256", sig_pss, data,
===============================================================================================
E
===============================================================================================
Error: test_sign_verify_pss(OpenSSL::TestPKeyRSA): OpenSSL::PKey::RSAError: digest not allowed (digest=SHA1)
/mnt/git/ruby/openssl/test/openssl/test_pkey_rsa.rb:191:in 'OpenSSL::PKey::RSA#sign_pss'
/mnt/git/ruby/openssl/test/openssl/test_pkey_rsa.rb:191:in 'OpenSSL::TestPKeyRSA#test_sign_verify_pss'
     188:     data = "Sign me!"
     189:     invalid_data = "Sign me?"
     190:
  => 191:     signature = key.sign_pss("SHA256", data, salt_length: 20, mgf1_hash: "SHA1")
     192:     assert_equal 256, signature.bytesize
     193:     assert_equal true,
     194:       key.verify_pss("SHA256", signature, data, salt_length: 20, mgf1_hash: "SHA1")
===============================================================================================
...
577 tests, 4186 assertions, 0 failures, 2 errors, 0 pendings, 3 omissions, 0 notifications
```

[1] https://en.wikipedia.org/wiki/Probabilistic_signature_scheme
[2] https://fedoraproject.org/wiki/Changes/OpenSSLDistrustSHA1SigVer

e0e771b76f
2025-04-08 17:46:42 +00:00
Kazuki Yamaguchi
6b5e187d0e [ruby/openssl] pkcs7: fix test failure on RHEL 9
The test case test_split_content fails on RHEL 9 and Fedora 41 because
their OpenSSL packages do not accept SHA-1 signatures. This was only
caught after commit 69fd7f8863 added the missing assertion.

While the example PKCS#7 structures could be simply regenerated with
SHA-256, this test case could be simplified because it is checking two
different things.

Replace test_split_content with separate test cases: one verifying
signed-data authenticatedAttributes and another for decoding BER input.

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

b32406b0c1
2025-04-03 17:58:30 +00:00
Kazuki Yamaguchi
3911113bc4 [ruby/openssl] pkcs7: update test case test_graceful_parsing_failure
Using test_pkcs7.rb as an example invalid input is not reliable because
we may happen to include a valid PKCS#7 PEM block in a heredoc.

76fead26d2
2025-04-03 17:58:29 +00:00
Samuel Chiang
6b5aa43291 [ruby/openssl] Skip PKCS7 with indefinite length test in AWS-LC
AWS-LC had been decoding the indefinite BER to an unusable output. We
should skip the test until indefinite BER decoding in AWS-LC is
properly fixed.

Changes:
1. AWS-LC will be looking to fix the parsing for indefinite BER
constructed strings in AWS-LC soon, so I've marked the test as `pend`
for now and removed the AWS-LC specific logic at the end.
2. I've added an assertion to verify that `OpenSSL::PKCS7.verify`
behaves correctly before doing content comparisons. I noticed this was
failing initially in AWS-LC, but that will be fixed soon as well. This
shouldn't effect OpenSSL/LibreSSL builds and should improve the test.

69fd7f8863
2025-03-30 13:46:28 +00:00
Jun Aruga
9ccba88160 [ruby/openssl] test_pkey_dh.rb: Merge 2 test_new_break tests to one test.
Merge 2 test_new_break tests to one test because it's easy to maintain the test.

446ff3e11f
2025-03-03 15:27:56 +00:00
Kazuki Yamaguchi
a6da77c9e9 [ruby/openssl] ssl: fix tests using TLS 1.1 or older
Commit aa7f03e18f broke test_minmax_version and test_fallback_scsv
on systems using OpenSSL 1.1.1 with a system-wide configuration file
that specifies MinProtocol=TLSv1.2.

20250228T003003Z.fail.html.gz
20250228T003003Z.fail.html.gz

These test cases were already broken before the commit, but they were
being skipped because check_supported_protocol_versions failed to detect
TLS 1.1 support. To avoid affected by the configuration file, explicitly
reset SSLContext#min_version when TLS 1.1 or older is required.

The test cases are also broken with OpenSSL 3.0 or later, but this is
not currently visible because it still fails to detect TLS 1.1 support.
This is caused by the default SSLContext#security_level value, as
OpenSSL 3.0 changed TLS 1.1 to be disabled at level 1.

6d0ea81b5e
2025-02-28 04:33:43 +00:00
Kazuki Yamaguchi
d4b8da66ca [ruby/openssl] ssl: refactor check_supported_protocol_versions
As reported in <https://github.com/ruby/ruby/pull/12823>,
check_supported_protocol_versions is unstable and occasionally fails
with Errno::ECONNABORTED during SSLSocket#connect on Windows.

When the server-side SSLContext specifies an unsupported SSL/TLS
protocol version, start_server accepts a TCP connection but closes it
without reading ClientHello, as SSLSocket#accept immediately raises an
exception. With Winsock, this can cause the client-side
SSLSocket#connect to raise Errno::ECONNABORTED.

While the simplest fix is to add rescue Errno::ECONNABORTED, this method
can be simplified. Instead, let's set up a server that accepts all
protocol versions and test client connections with different settings.

aa7f03e18f
2025-02-27 17:18:02 +00:00
Kazuki Yamaguchi
c0f3dcf795 [ruby/openssl] digest: correct assert_equal usage in test_sha3
assert_equal accepts an expected value as the first argument.

8faa1d89de
2025-02-27 17:04:32 +00:00
Kazuki Yamaguchi
f5a74bd645 [ruby/openssl] digest: always run SHA-3 and truncated SHA-2 tests
The "pend" are no longer necessary, as they work with all OpenSSL
variants we currently support. They were added in OpenSSL 1.1.1 and
LibreSSL 3.8.0. They are also supported by the current AWS-LC release.

This makes the SHA-3 tests run with AWS-LC correctly. AWS-LC does not
report SHA-3 in OpenSSL::Digest.digests.

e1a6e9c081
2025-02-27 17:04:32 +00:00
Kazuki Yamaguchi
9994a95790 [ruby/openssl] ssl: manually craft invalid SAN extensions in tests
Starting with LibreSSL 3.5, OpenSSL::X509::ExtensionFactory refuses to
create SAN extensions that are not valid according to RFC 6125. While
this behavior makes sense, we need such invalid extensions to test our
own validation routine. Let's construct SAN extensions manually instead.

b420d6d739
2025-02-27 17:04:16 +00:00
Jun Aruga
244363b23e [ruby/openssl] Use ENV["TEST_RUBY_OPENSSL_FIPS_ENABLED"] instead of OpenSSL::OPENSSL_FIPS.
As OpenSSL::OPENSSL_FIPS always returns true on OpenSSL >= 3.0.0, we cannot use
this constant as a flag to check whether the OpenSSL is FIPS or not.
See <d725783c5c/ext/openssl/ossl.c (L994-L1004)>.

Skip the test_fips_mode_get_with_fips_mode_set test in AWS-LC case.

Because we don't test `OpenSSL.fips_mode=` on AWS-LC for now. We cannot change
the value of the `OpenSSL.fips_mode` on AWS-LC.
The `OpenSSL.fips_mode` in AWS-LC behaves as follows.

On AWS-LC non-FIPS:
```
$ bundle exec ruby -I ./lib -ropenssl.so -e 'p OpenSSL.fips_mode'
false

$ bundle exec ruby -I ./lib -ropenssl.so -e 'OpenSSL.fips_mode = true; p OpenSSL.fips_mode'
-e:1:in 'OpenSSL.fips_mode=': Turning on FIPS mode failed (OpenSSL::OpenSSLError)
	from -e:1:in '<main>'

$ bundle exec ruby -I ./lib -ropenssl.so -e 'OpenSSL.fips_mode = false; p OpenSSL.fips_mode'
false
```

On AWS-LC FIPS:
```
$ bundle exec ruby -I ./lib -ropenssl.so -e 'p OpenSSL.fips_mode'
true

$ bundle exec ruby -I ./lib -ropenssl.so -e 'OpenSSL.fips_mode = false; p OpenSSL.fips_mode'
-e:1:in 'OpenSSL.fips_mode=': Turning off FIPS mode failed (OpenSSL::OpenSSLError)
	from -e:1:in '<main>'

$ bundle exec ruby -I ./lib -ropenssl.so -e 'OpenSSL.fips_mode = true; p OpenSSL.fips_mode'
true
```

fd3e3e722f
2025-02-27 17:01:57 +00:00
Samuel Chiang
fd882fb681 [ruby/openssl] test_ssl_session.rb: test adjustments to work with AWS-LC
The SSL SESSION files we were originally testing against use DHE and
SSLv3. AWS-LC happens to have no support for either and we have newer
possible alternatives available, so I've updated the respective
files to use ECDHE-RSA-AES256-SHA with TLS 1.1 and 1.2. I've verified
that these work as expected with all libcryptos we support.

There are also a few SSL session discrepencies in AWS-LC when
compared to OpenSSL.

1. AWS-LC has no support for internal session caching on the
   client-end.
2. AWS-LC supports internal session caching on the server, but
   SSL_get1_session does not return a resumable session with TLS 1.3
   in AWS-LC. Users have to use the SSL_CTX_sess_set_new_cb
   (ctx.session_new_cb in Ruby) to retrieve the resumable session
   ticket.
3. AWS-LC has no current support for external session caching in TLS
   1.3.

ca384b8e2f
2025-02-22 15:11:40 +00:00
Samuel Chiang
7a15ba48b5 [ruby/openssl] ssl: account for slight behavioral differences in AWS-LC
There are a few SSL discrepencies in AWS-LC when compared to OpenSSL.

1. AWS-LC has slightly different error messages (in all-caps).
2. AWS-LC has no support for DHE ciphersuites.
3. There are no concepts of SSL security levels within AWS-LC.
4. Similar to LibreSSL, there is no support for OPENSSL_CONF.

a60d050342
2025-02-22 15:11:40 +00:00
Samuel Chiang
4ec0e9e25d [ruby/openssl] pkey/ec: AWS-LC disallows serialization of explicit curves
65c5a772ea
2025-02-22 15:11:40 +00:00
Samuel Chiang
23465d8446 [ruby/openssl] pkey/dh: tweak break tests for AWS-LC
We reecently tweaked some break tests in test_pkey_dh.rb due to
different behavior with OpenSSL in FIPS mode.
AWS-LC does not inherit the same specific behavior, so tests
have been adjusted accordingly.

3117897dbc
2025-02-22 15:11:39 +00:00
Samuel Chiang
841d9f259d [ruby/openssl] pkey: EVP_DigestVerify doesn't return -1 in AWS-LC
EVP_DigestVerify in OpenSSL returns 0 to indicate a signature
verification failure and can return -1  to indicate other
failures, such as invalid ASN1 contents. ruby/openssl also
reflects that by returning false with 0 and raising an error
with -1.
EVP_DigestVerify in AWS-LC simply returns 0 for any failure.

be8ba76dc1
2025-02-22 15:11:39 +00:00
Samuel Chiang
f63a123606 [ruby/openssl] pkey: AWS-LC disallows parsing of invalid keys and params
OpenSSL allows invalid EC keys or DH params to be parsed. The consuming
application can then run parameter/key checks to check the validity of
the parameters. We happen to run tests to verify that this behaves as
expected.
AWS-LC on the other hand, directly raises an error and disallows the
invalid state to be parsed, rather than making it parsable and checking
the validity later. Relevant tests have been adjusted accordingly to
reflect this.

febe50be1b
2025-02-22 15:11:38 +00:00
Samuel Chiang
6263d0d16b [ruby/openssl] test_pkcs7.rb: skip AWS-LC's unsupported features
1. AWS-LC has no support for SMIME with PKCS7. That may change in the
   near future, so I've marked that with "pend" for now.
2. AWS-LC doesn't support printing of PKCS7 contents with
   PKCS7_print_ctx.
3. OpenSSL traditionally used indefinite-length encoding with
   ASN1_TFLG_NDEF in its implementation for PKCS7 EncryptedContent.
   AWS-LC uses explicit OCTET STRING headers to encode instead,
   which leads to a slight difference in serialized ASN1 contents
   from the two libraries.

78c585a9c2
2025-02-22 15:11:38 +00:00
Samuel Chiang
b995eee811 [ruby/openssl] asn1: adjusting an ASN1 test to use CONTEXT_SPECIFIC
AWS-LC's ASN1 parsing capabilities led to us examine some of our
ASN1 tests. One test in test_asn1.rb happens to use a tag number
of 8224. There are concerns with larger UNIVERSAL tags being
ambiguous with negative ASN1 Integers, so I've adjusted the test
to use CONTEXT_SPECIFIC instead with the same tag number (8224).

c73d9985ab
2025-02-22 15:11:38 +00:00
Samuel Chiang
c4a39d6ebc [ruby/openssl] test_config.rb: skip AWS-LC's unsupported features
AWS-LC has a few minor functionalities removed from NCONF_get_string.

1. Expanding of $foo to a previously-parsed value was removed.
2. OpenSSL falls back to using "default" with an unknown "section".
   AWS-LC does not support this behavior.
3. AWS-LC does not support parsing environment variables with "ENV"
   like LibreSSL.

e8de3bbd1e
2025-02-22 15:11:37 +00:00
Samuel Chiang
ee5af8860f [ruby/openssl] test_bn.rb: AWS-LC does not support BN::CONSTTIME
AWS-LC does not support BN_FLG_CONSTTIME due to its historically
inconsistent constant-time guarantees.

9875a01b5f
2025-02-22 15:11:37 +00:00
Samuel Chiang
f14995e212 [ruby/openssl] test_pkcs12.rb: don't use KEY_EX/SIG with AWS-LC
AWS-LC does not support the KEY_SIG or KEY_EX flags that were only ever
supported by old MSIE.

d50528b4e2
2025-02-22 15:11:37 +00:00
Samuel Chiang
6f3bd3769b [ruby/openssl] test_fips.rb: account for AWS-LC's FIPS mode
AWS-LC's FIPS mode is decided at compile time. FIPS in AWS-LC can't be
toggled on and off like OpenSSL, so tests that attempt to do so are
incompatible.

027de6732d
2025-02-22 15:11:36 +00:00
Kazuki Yamaguchi
c515da3d74 [ruby/openssl] ssl: remove cert_store from start_server test helper
OpenSSL::SSL::SSLContext#cert_store= uses SSL_CTX_set_cert_store(). The
store is used for verifying peer certificates and for building
certificate chains to be sent to the peer if there is no chain
explicitly provided by SSLContext#extra_chain_cert=.

Do not specify it in the common test helper start_server, as most
callers do not require either function. Instead, update individual test
cases that use client certificates to explicitly specify it in ctx_proc.
A more direct test case is added to verify the latter function.

9daecee615
2025-02-19 17:08:16 +00:00
Kazuki Yamaguchi
dedd05e9c8 [ruby/openssl] pkcs7: add a test case for the data content type
While it is not useful alone, it is still a valid content type. Some
methods on OpenSSL::PKCS7 are only meant to work with the signed-data
or enveloped-data content type. Add some assertions for their behavior
with unsupported content types. The next patches will update the
relevant code.

adb42b5b84
2025-02-11 16:42:25 +00:00
Samuel Chiang
06faf28558 [ruby/openssl] Add build support for AWS-LC
CI Changes
1. I've split the original patch up to make it easier to digest, but
that forces my hand to turn off testing in the AWS-LC CI for the time
being. However, do let me know if you would prefer to review the test
adjustments in the same PR and I can remove the temporary CI workaround.
2. AWS-LC has a few no-op functions and we use -Wdeprecated-declarations
to alert the consuming application of these. I've leveraged the
skip-warnings CI option so that the build doesn't fail.

Build Adjustments
1. AWS-LC FIPS mode is decided at compile time. This is different from
OpenSSL's togglable FIPS switch, so I've adjusted the build to account
for this.
2. AWS-LC does not support for the two KEY_SIG or KEY_EX flags that were
only ever supported by old MSIE.
3. AWS-LC has no current support for post handshake authentication in
TLS 1.3.
4. EC_GROUP structures for named curves in AWS-LC are constant, static,
and immutable by default. This means that the EC_GROUP_set_* functions
are essentially no-ops due to the immutability of the structure. We've
introduced a new API for consumers that depend on the OpenSSL's default
mutability of the EC_GROUP structure called
EC_GROUP_new_by_curve_name_mutable. Since Ruby has a bit of
functionality that's dependent on the mutability of these structures,
I've made the corresponding adjustments to allow things to work as
expected.

e53ec5a101
2025-02-11 15:35:03 +00:00
Kazuki Yamaguchi
7d10c22a86 [ruby/openssl] Revert "Skip a new test when old OpenSSL"
This reverts commit 8c96a69b0d.

This is no longer necessary since we do not support OpenSSL 1.1.0
anymore.

4987688cb4
2025-02-09 10:26:07 +00:00
Kazuki Yamaguchi
581dbcec79 [ruby/openssl] ssl: prefer SSLContext#max_version= in tests
Avoid using the deprecated OpenSSL::SSL::SSLContext#ssl_version= outside
the tests specifically written for it.

93a564dec2
2025-02-09 10:26:07 +00:00
Kazuki Yamaguchi
64a98decf2 [ruby/openssl] ssl: fix misuse of assert_handshake_error in tests
assert_handshake_error is useful for checking handshake failures
triggered by the peer, as the underlying socket may be closed
prematurely, leading to different exceptions depending on the platform
and timing.

However, when the local end aborts a handshake, the only possible
exception is OpenSSL::SSL::SSLError. Use stricter assertions in such
cases.

637ba65818
2025-02-09 10:26:07 +00:00
Kazuki Yamaguchi
5791c93f8e [ruby/openssl] ssl: refactor test case test_verify_mode_server_cert
Minimize the amount of code inside the assert_raise block to avoid
accidentally catching a wrong exception.

5089b2d311
2025-02-09 10:26:06 +00:00
Kazuki Yamaguchi
a8b36314ec [ruby/openssl] ssl: fix test case test_npn_advertised_protocol_too_long
The list of NPN protocols is validated in SSLContext#setup.

The assert_handshake_error is misleading. The client is unable to start
a handshake at all because the server is not running.

e8db6ffd9e
2025-02-09 10:26:06 +00:00
Kazuki Yamaguchi
1f4fc2e608 [ruby/openssl] ssl: remove start_server_version from tests
Use start_server instead of start_server_version.

start_server_version is a wrapper around start_server that forces the
server to a specific protocol version using the now-deprecated method
SSLSocket#ssl_version=, but it does more than that. The slightly
different method signature and default values are confusing. Let's
use start_server directly.

22ed31d77e
2025-02-09 10:26:06 +00:00
Kazuki Yamaguchi
237c71fc29 [ruby/openssl] ssl: remove start_immediately kwarg from test helper start_server
The keyword argument is no longer used by any test cases.

2f31605d47
2025-02-09 10:26:05 +00:00
Jun Aruga
adbf9c5b36 [ruby/openssl] test_ssl.rb: Test respecting system default min.
7de5ff583a
2025-02-06 14:10:34 +00:00
Kazuki Yamaguchi
f84d75eecc [ruby/openssl] pkey/ec: remove deprecated PKey::EC::Point#mul(ary, ary [, bn]) form
The method has two forms, each corresponding to EC_POINT_mul() and
EC_POINTs_mul(). The latter form does not work with any OpenSSL or
LibreSSL versions that are still supported by upstream.

The latter form has an extremely confusing behavior, too, and using it
would print a deprecation warning since commit 812de4253d in 2020,
which went to 3.0.0. Let's remove it.

7343d3c559
2025-02-03 09:47:48 +00:00
Kazuki Yamaguchi
5a14f53695 [ruby/openssl] ssl: separate SSLContext#min_version= and #max_version=
Make these methods simple wrappers around
SSL_CTX_set_{min,max}_proto_version().

When we introduced these methods in commit 18603949d3 [1], which went
to v2.1.0, we added a private method to SSLContext that set both the
minimum and maximum protocol versions at the same time. This was to
allow emulating the behavior using SSL options on older OpenSSL versions
that lack SSL_CTX_set_{min,max}_proto_version(). Since we no longer
support OpenSSL 1.0.2, the related code has already been removed.

In OpenSSL 1.1.1 or later, setting the minimum or maximum version to 0
is not equivalent to leaving it unset. Similar to SSL options, which we
avoid overwriting as of commit 00bec0d905 and commit 77c3db2d65 [2],
a system-wide configuration file may define a default protocol version
bounds. Setting the minimum version should not unset the maximum
version, and vice versa.

[1] https://github.com/ruby/openssl/pull/142
[2] https://github.com/ruby/openssl/pull/767

5766386321
2025-02-03 09:46:03 +00:00
Kazuki Yamaguchi
1b731c1f43 [ruby/openssl] pkey: avoid calling i2d_PUBKEY family on an incomplete key
Call ossl_pkey_check_public_key() to ensure that
EVP_PKEY_missing_parameters() passes. This check should be cheap.

DSA#{to_der,to_pem,export,to_s} and PKey#{public_to_der,public_to_pem}
cause a segfault if the receiver is an empty DSA instance with no
parameters set.

Fixes <https://github.com/ruby/openssl/issues/845>.

5aeed935e5
2025-01-29 17:14:41 +00:00
Kazuki Yamaguchi
81c83fd79f [ruby/openssl] test/openssl/test_ossl.rb: use clock_gettime for measuring time
The benchmark library is planned to become a bundled gem in Ruby 3.5.
While we can add it in our Gemfile, it is only used in
test_memcmp_timing and the usage can be easily replaced with a few
Process.clock_gettime calls.

9a746ed1a4
2025-01-29 17:14:40 +00:00
Kazuki Yamaguchi
87316d58fa [ruby/openssl] pkey: change PKey::{RSA,DSA,DH}#params to use nil for missing parameters
The returned Hash from these methods contain 0 in place of a missing
parameter in the key, for example:

	pkey = OpenSSL::PKey.read(OpenSSL::PKey::RSA.new(2048).public_to_pem)
	pp pkey.params
	#=>
	# {"n"=>#<OpenSSL::BN 2869346734[...snip]>,
	#  "e"=>#<OpenSSL::BN 65537>,
	#  "d"=>#<OpenSSL::BN 0>,
	#  "p"=>#<OpenSSL::BN 0>,
	#  "q"=>#<OpenSSL::BN 0>,
	#  "dmp1"=>#<OpenSSL::BN 0>,
	#  "dmq1"=>#<OpenSSL::BN 0>,
	#  "iqmp"=>#<OpenSSL::BN 0>}

Let's use nil instead, which is more appropriate for indicating a
missing value.

f247ec3dec
2025-01-23 01:45:52 +09:00
Kazuki Yamaguchi
47fe59cd82 [ruby/openssl] pkey: add tests for PKey::{RSA,DSA,DH}#params
Add missing test cases to verify the current behavior. The next patch
will rewrite those methods.

c0e0669f9b
2025-01-23 01:45:51 +09:00
Kazuki Yamaguchi
72480389d1 [ruby/openssl] ssl: fix SSLSocket#sysread leaking locktmp String on timeout
Commit 3bbf5178a9 made blocking methods on SSLSocket follow the
IO#timeout= value. The commit changed io_wait_readable() to potentially
raise an exception without unlocking the String.

The String is currently locked for the entire duration of a #sysread
method call. This does not seem to be necessary, as SSL_read() does not
require that the same buffer is specified when retrying. Locking the
String during each SSL_read() call should be sufficient.

8f791d73f5
2025-01-22 16:45:19 +00:00
Kazuki Yamaguchi
43c48e3030 [ruby/openssl] Require OpenSSL 1.1.1 or later
Drop support for OpenSSL 1.1.0. OpenSSL 1.1.0 was a non-LTS release and
it has reached upstream EOL in 2019-12 along with OpenSSL 1.0.2.
Distributions that shipped with OpenSSL 1.1.0 include:

 - Debian 9 (EOL 2022-06)
 - Ubuntu 18.04 LTS (EOL 2023-04)

ba83abe920
2025-01-21 18:14:14 +00:00
Kazuki Yamaguchi
e7bd1d1a9a [ruby/openssl] pkey/dh: do not skip test_params_ok? on LibreSSL
cd91cef590
2025-01-21 18:14:12 +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
1b515d1c37 [ruby/openssl] ssl: update test_verify_hostname_on_connect for LibreSSL
This reverts the change made to this test case in commit a0e98d48c9
(Enhance TLS 1.3 support on LibreSSL 3.2/3.3, 2020-12-03).

Part of the test case was skipped on LibreSSL because LibreSSL 3.2.2
introduced a stricter check during creation of the extension. The check
was then relaxed in LibreSSL 3.4.0.

187b176ecd
2025-01-14 12:38:17 +00:00
Kazuki Yamaguchi
0fb64bda9b [ruby/openssl] Require LibreSSL 3.9 or later
Drop support for LibreSSL 3.1-3.8. LibreSSL 3.8 has reached its EOL in
2024-10.

f33d611f9f
2025-01-14 12:38:16 +00:00
Jean Boussier
4f79485889 [ruby/openssl] Refactor buffer usage to only use append_as_bytes
28f2901c48
2025-01-14 11:54:47 +00:00