aboutsummaryrefslogtreecommitdiffstats
path: root/test/openssl
Commit message (Collapse)AuthorAgeFilesLines
* [ruby/openssl] Use SHA256 instead of SHA1 where needed in tests.Jarek Prokop2022-12-138-40/+43
| | | | | | | Systems such as RHEL 9 are moving away from SHA1 disabling it completely in default configuration. https://github.com/ruby/openssl/commit/32648da2f6
* [ruby/openssl] add BN#mod_sqrtBen Toews2022-10-171-0/+6
| | | | https://github.com/ruby/openssl/commit/4619ab3e76
* [ruby/openssl] Add support to SSL_CTX_set_keylog_callbackChristophe De La Fuente2022-10-171-0/+48
| | | | | | | | | | | | | | | - This callback is invoked when TLS key material is generated or received, in order to allow applications to store this keying material for debugging purposes. - It is invoked with an `SSLSocket` and a string containing the key material in the format used by NSS for its SSLKEYLOGFILE debugging output. - This commit adds the Ruby binding `keylog_cb` and the related tests - It is only compatible with OpenSSL >= 1.1.1. Even if LibreSSL implements `SSL_CTX_set_keylog_callback()` from v3.4.2, it does nothing (see https://github.com/libressl-portable/openbsd/commit/648d39f0f035835d0653342d139883b9661e9cb6) https://github.com/ruby/openssl/commit/3b63232cf1
* [ruby/openssl] pkey/ec: check existence of public key component before exportingKazuki Yamaguchi2022-10-171-0/+2
| | | | | | | | | | | | | i2d_PUBKEY_bio() against an EC_KEY without the public key component trggers a null dereference. This is a regression introduced by commit https://github.com/ruby/openssl/commit/56f0d34d63fb ("pkey: refactor #export/#to_pem and #to_der", 2017-06-14). Fixes https://github.com/ruby/openssl/pull/527#issuecomment-1220504524 Fixes https://github.com/ruby/openssl/issues/369#issuecomment-1221554057 https://github.com/ruby/openssl/commit/f6ee0fa4de
* [ruby/openssl] pkey: restore support for decoding "openssl ecparam -genkey" ↵Kazuki Yamaguchi2022-10-171-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | output Scan through the input for a private key, then fallback to generic decoder. OpenSSL 3.0's OSSL_DECODER supports encoded key parameters. The PEM header "-----BEGIN EC PARAMETERS-----" is used by one of such encoding formats. While this is useful for OpenSSL::PKey::PKey, an edge case has been discovered. The openssl CLI command line "openssl ecparam -genkey" prints two PEM blocks in a row, one for EC parameters and another for the private key. Feeding the whole output into OSSL_DECODER results in only the first PEM block, the key parameters, being decoded. Previously, ruby/openssl did not support decoding key parameters and it would decode the private key PEM block instead. While the new behavior is technically correct, "openssl ecparam -genkey" is so widely used that ruby/openssl does not want to break existing applications. Fixes https://github.com/ruby/openssl/pull/535 https://github.com/ruby/openssl/commit/d486c82833
* [ruby/openssl] pkey/dsa: let PKey::DSA.generate choose appropriate q sizeKazuki Yamaguchi2022-10-171-0/+19
| | | | | | | | | | | | | DSA parameters generation via EVP_PKEY_paramgen() will not automatically adjust the size of q value but uses 224 bits by default unless specified explicitly. This behavior is different from the now-deprecated DSA_generate_parameters_ex(), which PKey::DSA.generate used to call. Fixes https://github.com/ruby/openssl/issues/483 Fixes: https://github.com/ruby/openssl/commit/1800a8d5ebaf ("pkey/dsa: use high level EVP interface to generate parameters and keys", 2020-05-17) https://github.com/ruby/openssl/commit/0105975a0b
* [ruby/openssl] hmac: use EVP_PKEY_new_raw_private_key() if availableKazuki Yamaguchi2022-10-171-0/+8
| | | | | | | | | | | | | | | | Current OpenSSL 3.0.x release has a regression with zero-length MAC keys. While this issue should be fixed in a future release of OpenSSL, we can use EVP_PKEY_new_raw_private_key() in place of the problematic EVP_PKEY_new_mac_key() to avoid the issue. OpenSSL 3.0's man page recommends using it regardless: > EVP_PKEY_new_mac_key() works in the same way as > EVP_PKEY_new_raw_private_key(). New applications should use > EVP_PKEY_new_raw_private_key() instead. Fixes https://github.com/ruby/openssl/issues/369#issuecomment-1224912710 https://github.com/ruby/openssl/commit/4293f18b1f
* [ruby/openssl] ssl: enable generating keying material from SSL sessionsmadblobfish2022-10-171-0/+13
| | | | | | Add OpenSSL::SSL::SSLSocket#export_keying_material to support RFC 5705 https://github.com/ruby/openssl/commit/65530b887e
* [ruby/openssl] Check if the option is an Hash in `pkey_ctx_apply_options0()`Nobuhiro IMAI2022-10-171-0/+5
| | | | | | causes SEGV if it is an Array or something like that. https://github.com/ruby/openssl/commit/ef23525210
* [ruby/openssl] [CI] TestHMAC#test_dup - remove 'pend' for OpenSSL 3MSP-Greg2022-10-171-1/+0
| | | | https://github.com/ruby/openssl/commit/626b0434a6
* [ruby/openssl] Skip a new test when old OpenSSLNobuyoshi Nakada2022-07-091-0/+4
| | | | | | | It does not raise an error when setting an invalid value to SSLContext ciphers on Ubuntu 18.04. https://github.com/ruby/openssl/commit/8c96a69b0d
* [ruby/openssl] Strip trailing spaces [ci skip]Nobuyoshi Nakada2022-07-091-2/+2
| | | | https://github.com/ruby/openssl/commit/862d92de93
* [ruby/openssl] Let OpenSSL choose the digest if digest for ↵Jarek Prokop2022-07-081-1/+1
| | | | | | Openssl::OCSP::BasicResponse#sign is nil. https://github.com/ruby/openssl/commit/27efcd7e1c
* [ruby/openssl] Fix test of cipher name to pass in LibreSSL 3.4Jeremy Evans2022-07-081-1/+5
| | | | | | LibreSSL 3.5 switched the cipher naming to match OpenSSL. https://github.com/ruby/openssl/commit/bf198278bd
* [ruby/openssl] Add 'ciphersuites=' method to allow setting of TLSv1.3 cipher ↵twkmd122022-07-081-0/+89
| | | | | | | | suites along with some unit tests (https://github.com/ruby/openssl/pull/493) Add OpenSSL::SSL::SSLContext#ciphersuites= method along with unit tests. https://github.com/ruby/openssl/commit/12250c7cef
* [ruby/openssl] Skip optional wildcard SAN tests on LibreSSL 3.5.0+Jeremy Evans2022-07-081-0/+6
| | | | | | | | | | | | RFC 6066 states how some wildcard SAN entries MAY be handled, but it does not say they MUST be handled. LibreSSL 3.5.0 only handles suffix wildcard SANs, not prefix wildcard SANs, or interior wildcard SANs, so return early from the wildcard SAN tests on LibreSSL 3.5.0. Fixes #471 https://github.com/ruby/openssl/commit/717d7009d6
* [ruby/openssl] Add tast cases to OpenSSL::BN using ractorYusuke Nakamura2021-12-251-0/+25
| | | | | | | | OpenSSL::BN has been make ractor-safed in 9e7cf9e , but there was no test. And to use 'ractor' annotation, update test-unit to v3.4.6 or higher. https://github.com/ruby/openssl/commit/7541a66911
* [ruby/openssl] ssl: update test_options_disable_versionsKazuki Yamaguchi2021-12-201-35/+40
| | | | | | | Use the combination of TLS 1.2 and TLS 1.3 instead of TLS 1.1 and TLS 1.2 so that will the test case will be run on latest platforms. https://github.com/ruby/openssl/commit/e168df0f35
* [ruby/openssl] ssl: update test_accept_errors_include_peeraddr test caseKazuki Yamaguchi2021-12-201-6/+4
| | | | | | | Use a different invalid data example to prevent SSLSocket#accept from reaching EOF. https://github.com/ruby/openssl/commit/2e089c1916
* [ruby/openssl] hmac: skip test_dup on OpenSSL 3.0 for nowKazuki Yamaguchi2021-12-201-0/+1
| | | | | | | | EVP_MD_CTX_copy() doesn't seem to work as intended on HMAC EVP_MD_CTX on OpenSSL 3.0.0 and causes a double free. I haven't found the root problem yet, but let's skip the test case for now. https://github.com/ruby/openssl/commit/4699581639
* [ruby/openssl] cipher: update test_ciphersKazuki Yamaguchi2021-12-201-8/+5
| | | | | | | Do not attempt to actually use all algorithms. Not all algorithms listed in OpenSSL::Cipher.ciphers are always available. https://github.com/ruby/openssl/commit/91d04f991f
* [ruby/openssl] pkey: deprecate PKey#set_* methodsKazuki Yamaguchi2021-12-204-68/+121
| | | | | | | | | | | | | | | | | | | | | | | OpenSSL 3.0 made EVP_PKEY immutable. This means we can only have a const pointer of the low level struct and the following methods can no longer be provided when linked against OpenSSL 3.0: - OpenSSL::PKey::RSA#set_key - OpenSSL::PKey::RSA#set_factors - OpenSSL::PKey::RSA#set_crt_params - OpenSSL::PKey::DSA#set_pqg - OpenSSL::PKey::DSA#set_key - OpenSSL::PKey::DH#set_pqg - OpenSSL::PKey::DH#set_key - OpenSSL::PKey::EC#group= - OpenSSL::PKey::EC#private_key= - OpenSSL::PKey::EC#public_key= There is no direct replacement for this functionality at the moment. I plan to introduce a wrapper around EVP_PKEY_fromdata(), which takes all key components at once to construct an EVP_PKEY. https://github.com/ruby/openssl/commit/6848d2d969
* [ruby/openssl] pkey/ec: deprecate OpenSSL::PKey::EC#generate_key!Kazuki Yamaguchi2021-12-201-8/+13
| | | | | | | | OpenSSL::PKey::EC#generate_key! will not work on OpenSSL 3.0 because keys are made immutable. Users should use OpenSSL::PKey.generate_key instead. https://github.com/ruby/openssl/commit/5e2e66cce8
* [ruby/openssl] pkey/dh: deprecate OpenSSL::PKey::DH#generate_key!Kazuki Yamaguchi2021-12-201-8/+10
| | | | | | | | OpenSSL::PKey::DH#generate_key! will not work on OpenSSL 3.0 because keys are made immutable. Users should use OpenSSL::PKey.generate_key instead. https://github.com/ruby/openssl/commit/8ee6a582c7
* [ruby/openssl] pkey: test parsing concatenated PEM stringKazuki Yamaguchi2021-12-201-0/+6
| | | | | | | | | | | | | PEM-encoded private keys are sometimes stored together with irrelevant PEM blocks, such as the corresponding X.509 certificate. PEM_read_bio_*() family automatically skips unknown PEM blocks, but on OpenSSL 3.0 we will be using the new OSSL_DECODER API instead due to some breaking changes around the password callback. Let's add a test case so that we won't break the current behavior. https://github.com/ruby/openssl/commit/8c185e0ae5
* test/openssl/test_ssl: adjust certificate expiry dateKazuki Yamaguchi2021-11-111-1/+2
| | | | | | | | | | | | | test_connect_certificate_verify_failed_exception_message occasionally fails. Is it possible that OpenSSL sees a different clock from Ruby by more than 10 seconds? http://ci.rvm.jp/logfiles/brlog.trunk-random0.20211111-072828 Let's give more time after the certificate expiration date to see if this fixes the flakiness. We had similar occasional failures in test_x509store.rb before, which disappeared after ruby/ruby commit 7930a352a57c and ruby/openssl commit fb2fcbb13734.
* [ruby/openssl] Fix typos [ci skip]Nobuyoshi Nakada2021-11-031-1/+1
| | | | https://github.com/ruby/openssl/commit/708ebf2f7a
* [ruby/openssl] ssl: disallow reading/writing to unstarted SSL socketKazuki Yamaguchi2021-11-011-51/+12
| | | | | | | | | | | | | | | OpenSSL::SSL::SSLSocket allowed #read and #write to be called before an SSL/TLS handshake is completed. They passed unencrypted data to the underlying socket. This behavior is very odd to have in this library. A verbose mode warning "SSL session is not started yet" was emitted whenever this happened. It also didn't behave well with OpenSSL::Buffering. Let's just get rid of it. Fixes: https://github.com/ruby/openssl/issues/9 https://github.com/ruby/openssl/commit/bf780748b3
* [ruby/openssl] bn: make BN.pseudo_rand{,_range} an alias of BN.rand{,_range}Kazuki Yamaguchi2021-10-251-0/+4
| | | | | | | | BN_pseudo_rand() and BN_pseudo_rand_range() are deprecated in OpenSSL 3.0. Since they are identical to their non-'pseudo' version anyway, let's make them alias. https://github.com/ruby/openssl/commit/2d34e85ddf
* [ruby/openssl] test/openssl/test_ssl: use assert_raise in test_bad_socketKazuki Yamaguchi2021-10-231-1/+1
| | | | | | The Ruby tree disallows assert_raises. https://github.com/ruby/openssl/commit/9b4f761e74
* [ruby/openssl] Raise an exception if the IO object passed to SSLSocket isn't ↵Aaron Patterson2021-10-231-0/+11
| | | | | | | | | | | | | | | | | | | a file SSLSocket#connect eventually calls `GetOpenFile` in order to get the underlying file descriptor for the IO object passed in on initialization. `GetOpenFile` assumes that the Ruby object passed in is a T_FILE object and just casts it to a T_FILE without any checks. If you pass an object that *isn't* a T_FILE to that function, the program will segv. Since we assume the IO object is a file in the `connect` method, this commit adds a `CheckType` in the initialize method to ensure that the IO object is actually a T_FILE. If the object *isn't* a T_FILE, this class will segv on `connect`, so I think this is a backwards compatible change. https://github.com/ruby/openssl/commit/919fa44ec2
* [ruby/openssl] test/openssl/test_pkey_rsa: disable test_no_private_exp on ↵Kazuki Yamaguchi2021-10-231-1/+1
| | | | | | | | | OpenSSL 3.0 OpenSSL::PKey::RSA#set_key does not exist when built with OpenSSL 3.0, so it is not possible to create an RSA object with incomplete state. https://github.com/ruby/openssl/commit/ca03c9c070
* [ruby/openssl] test/openssl/test_pkey: use EC keys for ↵Kazuki Yamaguchi2021-10-231-16/+11
| | | | | | | | | | PKey.generate_parameters tests OpenSSL 3.0 refuses to generate DSA parameters shorter than 2048 bits, but generating 2048 bits parameters takes very long time. Let's use EC in these test cases instead. https://github.com/ruby/openssl/commit/c732387ee5
* [ruby/openssl] test/openssl/test_ssl: fix illegal SAN extensionKazuki Yamaguchi2021-10-231-2/+1
| | | | | | | | A certificate can only have one SubjectAltName extension. OpenSSL 3.0 performs a stricter validation and certificates containing multiple SANs will be rejected. https://github.com/ruby/openssl/commit/558cfbe5f5
* [ruby/openssl] test/openssl/test_pkcs12: fix test failures with OpenSSL 3.0Kazuki Yamaguchi2021-10-231-148/+149
| | | | | | | | | | | OpenSSL's PKCS12_create() by default uses pbewithSHAAnd40BitRC2-CBC for encryption of the certificates. However, in OpenSSL 3.0, the algorithm is part of the legacy provider and is not enabled by default. Specify another algorithm that is still in the default provider for these test cases. https://github.com/ruby/openssl/commit/998406d18f
* [ruby/openssl] test/openssl/test_ssl: relax regex to match OpenSSL's error ↵Kazuki Yamaguchi2021-10-231-1/+3
| | | | | | | | | | message OpenSSL 3.0 slightly changed the error message for a certificate verification failure when an untrusted self-signed certificate is found in the chain. https://github.com/ruby/openssl/commit/b5a0a19850
* [ruby/openssl] test/openssl/test_digest: do not test constants for legacy ↵Kazuki Yamaguchi2021-10-231-1/+1
| | | | | | | | | | algorithms Remove availability test for MD4 and RIPEMD160 as they are considered legacy and may be missing depending on the compile-time options of OpenSSL. OpenSSL 3.0 by default disables them. https://github.com/ruby/openssl/commit/a3e59f4c2e
* [ruby/openssl] test/openssl/test_ssl: assume ECC supportKazuki Yamaguchi2021-10-234-24/+14
| | | | | | | | | | Disabling ECC support of OpenSSL is impractical nowadays. We still try to have the C extension compile on no-ec builds (as well as no-dh or no-engine, etc.) as long as we can, but keeping test cases for such an extreme scenario is not worth the effort. https://github.com/ruby/openssl/commit/2cd01d4676
* [ruby/openssl] test/openssl/test_ssl: assume TLS 1.2 supportKazuki Yamaguchi2021-10-233-55/+26
| | | | | | | Current versions of OpenSSL and LibreSSL all support TLS 1.2, so there is no need for checking the availability. https://github.com/ruby/openssl/commit/a175a41529
* [ruby/openssl] test/openssl/utils: remove dup_public helper methodKazuki Yamaguchi2021-10-235-51/+44
| | | | | | | | It uses deprecated PKey::{RSA,DSA,DH}#set_* methods, which will not work with OpenSSL 3.0. The same can easily be achieved using PKey#public_to_der regardless of the key kind. https://github.com/ruby/openssl/commit/7b66eaa2db
* [ruby/openssl] require Ruby 2.6 or laterKazuki Yamaguchi2021-10-161-9/+3
| | | | | | | | | | Drop support for Ruby 2.3, 2.4, and 2.5. As of 2021-10, Ruby 2.6 is the oldest version that still receives security fixes from the Ruby core team, so it doesn't make much sense to keep code for those ancient versions. https://github.com/ruby/openssl/commit/3436bd040d
* [ruby/openssl] test/openssl/test_ssl: use TLS 1.2 for finished_messages on ↵Kazuki Yamaguchi2021-10-161-0/+1
| | | | | | | | | LibreSSL LibreSSL 2.2.x has a bug in the Finished message handling with TLS 1.3. This is fixed by LibreSSL 3.3.2. https://github.com/ruby/openssl/commit/0bea59d245
* [ruby/openssl] fix segv in Timestamp::{Request,Response,TokenInfo}.newNobuhiro IMAI2021-10-161-0/+18
| | | | | | prevent `ossl_ts_*_free()` from calling when `d2i_TS_*_bio()` failed. https://github.com/ruby/openssl/commit/b29e215786
* [ruby/openssl] Fixed misspellingsNobuyoshi Nakada2021-10-161-8/+8
| | | | | | | | | | [ This is a backport to the 2.1 branch. ] Fixed misspellings reported at [Bug #16437], for default gems. (cherry picked from commit ruby/ruby@e68999c82c4863d33a6f893661fba1b7538c5671) https://github.com/ruby/openssl/commit/0f43789503
* [ruby/openssl] ssl: add SSLContext#tmp_dh=Kazuki Yamaguchi2021-10-161-7/+17
| | | | | | | | | | | | | | | | | | | | Provide a wrapper of SSL_set0_tmp_dh_pkey()/SSL_CTX_set_tmp_dh(), which sets the DH parameters used for ephemeral DH key exchange. SSLContext#tmp_dh_callback= already exists for this purpose, as a wrapper around SSL_CTX_set_tmp_dh_callback(), but it is considered obsolete and the OpenSSL API is deprecated for future removal. There is no practical use case where an application needs to use different DH parameters nowadays. This was originally introduced to support export grade ciphers. RDoc for #tmp_dh_callback= is updated to recommend the new #tmp_dh=. Note that current versions of OpenSSL support automatic ECDHE curve selection which is enabled by default. SSLContext#tmp_dh= should only be necessary if you must allow ancient clients which don't support ECDHE. https://github.com/ruby/openssl/commit/aa43da4f04
* Use Test::Unit::PendedError instead of MiniTest::Skip for test-unit migrationHiroshi SHIBATA2021-09-061-2/+1
|
* test/openssl/test_x509cert.rb: Prevent "unused variable" warningYusuke Endoh2021-07-191-1/+1
|
* [ruby/openssl] Include peer socket IP address in errorsVinicius Stock2021-07-181-0/+27
| | | | https://github.com/ruby/openssl/commit/8a1e3f5085
* [ruby/openssl] Add OpenSSL::BN#set_flags and #get_flagsYusuke Endoh2021-07-181-0/+23
| | | | | | | | | | | | | | | | Also, OpenSSL::BN::CONSTTIME is added. OpenSSL itself had a feature that was vulnerable against a side-channel attack. The OpenSSL authors determined that it was not a security issue, and they have already fixed the issue by using BN_set_flags. https://github.com/openssl/openssl/pull/13888 If a Ruby OpenSSL user was faced with a similar issue, they couldn't prevent the issue because Ruby OpenSSL lacks a wrapper to BN_set_flags. For the case, this change introduces the wrapper. https://github.com/ruby/openssl/commit/1e565eba89
* [ruby/openssl] pkey: implement PKey#sign_raw, #verify_raw, and #verify_recoverKazuki Yamaguchi2021-07-183-31/+93
| | | | | | | | | | | | | | | Add a variant of PKey#sign and #verify that do not hash the data automatically. Sometimes the caller has the hashed data only, but not the plaintext to be signed. In that case, users would have to use the low-level API such as RSA#private_encrypt or #public_decrypt directly. OpenSSL 1.0.0 and later supports EVP_PKEY_sign() and EVP_PKEY_verify() which provide the same functionality as part of the EVP API. This patch adds wrappers for them. https://github.com/ruby/openssl/commit/16cca4e0c4