ruby/test/openssl
Kazuki Yamaguchi 01d368e7b0 [ruby/openssl] ssl: raise SSLError if loading ca_file or ca_path fails
When compiled with OpenSSL <= 1.1.1, OpenSSL::SSL::SSLContext#setup
does not raise an exception on an error return from
SSL_CTX_load_verify_locations(), but instead only prints a verbose-mode
warning. This is not helpful since it very likely indicates an actual
error, such as the specified file not being readable.

Also, OpenSSL's error queue is not correctly cleared:

	$ ruby -w -ropenssl -e'OpenSSL.debug=true; ctx=OpenSSL::SSL::SSLContext.new; ctx.ca_file="bad-path"; ctx.setup; pp OpenSSL.errors'
	-e:1: warning: can't set verify locations
	["error:02001002:system library:fopen:No such file or directory",
	 "error:2006D080:BIO routines:BIO_new_file:no such file",
	 "error:0B084002:x509 certificate routines:X509_load_cert_crl_file: system lib"]

The behavior is currently different when compiled with OpenSSL >= 3.0:
SSLError is raised if SSL_CTX_load_verify_file() or
SSL_CTX_load_verify_dir() fails.

This inconsistency was unintentionally introduced by commit 5375a55ffc
("ssl: use SSL_CTX_load_verify_{file,dir}() if available", 2020-02-22).
However, raising SSLError seems more appropriate in this situation.
Let's adjust the OpenSSL <= 1.1.1 code so that it behaves the same way
as the OpenSSL >= 3.0 code currently does.

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

7eb10f7b75
2023-08-16 14:48:41 +09:00
..
fixtures [ruby/openssl] CI: Add OpenSSL FIPS mode case. 2023-05-19 09:25:10 +09:00
test_asn1.rb [ruby/openssl] test/openssl/test_asn1.rb: remove pend for unsupported LibreSSL versions 2022-12-23 09:39:15 +09:00
test_bn.rb [ruby/openssl] Fix modular square root test with LibreSSL >= 3.8 2023-06-19 01:57:09 +09:00
test_buffering.rb
test_cipher.rb [ruby/openssl] Allow empty string to OpenSSL::Cipher#update 2022-12-13 18:07:41 +09:00
test_config.rb [ruby/openssl] Fixed misspellings 2021-10-16 18:25:11 +09:00
test_digest.rb [ruby/openssl] test/openssl/test_digest: do not test constants for legacy algorithms 2021-10-23 13:38:37 +09:00
test_engine.rb [ruby/openssl] Do not require test file in a forked process in tests 2023-01-27 11:30:13 +09:00
test_fips.rb [ruby/openssl] Implement FIPS functions on OpenSSL 3. 2023-05-19 09:25:10 +09:00
test_hmac.rb [ruby/openssl] Revert "Skip OpenSSL::TestHMAC#test_dup when running with RHEL9" 2023-05-19 09:25:11 +09:00
test_kdf.rb
test_ns_spki.rb [ruby/openssl] Use SHA256 instead of SHA1 where needed in tests. 2022-12-13 18:07:41 +09:00
test_ocsp.rb [ruby/openssl] Let OpenSSL choose the digest if digest for Openssl::OCSP::BasicResponse#sign is nil. 2022-07-08 23:18:22 +09:00
test_ossl.rb
test_pair.rb [ruby/openssl] test/openssl/test_ssl.rb: do not run SSL tests if not available 2022-12-23 09:39:15 +09:00
test_pkcs7.rb
test_pkcs12.rb [ruby/openssl] test/openssl/test_pkcs12: fix test failures with OpenSSL 3.0 2021-10-23 13:38:38 +09:00
test_pkey.rb [ruby/openssl] Add support for raw private/public keys 2023-07-12 23:40:58 +09:00
test_pkey_dh.rb [ruby/openssl] pkey: deprecate PKey#set_* methods 2021-12-20 23:42:02 +09:00
test_pkey_dsa.rb [ruby/openssl] Use SHA256 instead of SHA1 where needed in tests. 2022-12-13 18:07:41 +09:00
test_pkey_ec.rb [ruby/openssl] pkey/ec: check private key validity with OpenSSL 3 2022-12-23 09:39:15 +09:00
test_pkey_rsa.rb [ruby/openssl] Use SHA256 instead of SHA1 where needed in tests. 2022-12-13 18:07:41 +09:00
test_provider.rb [ruby/openssl] add OpenSSL Provider support 2023-06-19 17:45:51 +09:00
test_random.rb
test_ssl.rb [ruby/openssl] ssl: raise SSLError if loading ca_file or ca_path fails 2023-08-16 14:48:41 +09:00
test_ssl_session.rb [ruby/openssl] test/openssl/test_ssl.rb: do not run SSL tests if not available 2022-12-23 09:39:15 +09:00
test_ts.rb [ruby/openssl] fix segv in Timestamp::{Request,Response,TokenInfo}.new 2021-10-16 18:34:35 +09:00
test_x509attr.rb
test_x509cert.rb [ruby/openssl] Use SHA256 instead of SHA1 where needed in tests. 2022-12-13 18:07:41 +09:00
test_x509crl.rb [ruby/openssl] Use SHA256 instead of SHA1 where needed in tests. 2022-12-13 18:07:41 +09:00
test_x509ext.rb
test_x509name.rb
test_x509req.rb [ruby/openssl] Use SHA256 instead of SHA1 where needed in tests. 2022-12-13 18:07:41 +09:00
test_x509store.rb
ut_eof.rb [ruby/openssl] Add SSLSocket#getbyte 2021-07-18 17:44:53 +09:00
utils.rb [ruby/openssl] Drop a common logic disabling the FIPS mode in the tests. 2023-06-19 01:57:09 +09:00