aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* x509*: fix error queue leak in #extensions= and #attributes= methodsky/x509-delete-attr-cleanupKazuki Yamaguchi2022-09-024-12/+12
| | | | | | X509at_delete_attr() in OpenSSL master puts an error queue entry if there is no attribute left to delete. We must either clear the error queue, or try not to call it when the list is already empty.
* Merge pull request #531 from no6v/pkey-sign-option-type-checkKazuki Yamaguchi2022-08-112-0/+6
|\ | | | | OpenSSL::PKey::PKey#sign etc. with wrong type option causes SEGV
| * Check if the option is an Hash in `pkey_ctx_apply_options0()`Nobuhiro IMAI2022-08-082-0/+6
|/ | | | causes SEGV if it is an Array or something like that.
* Merge pull request #488 from jeremyevans/skip-san-wildcard-libresslKazuki Yamaguchi2022-01-051-0/+6
|\ | | | | Skip optional wildcard SAN tests on LibreSSL 3.5.0+
| * Skip optional wildcard SAN tests on LibreSSL 3.5.0+Jeremy Evans2022-01-041-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
* Ruby/OpenSSL 3.0.0v3.0.0ky/release-3.0.0Kazuki Yamaguchi2021-12-253-2/+104
|
* remove docker-compose filesKazuki Yamaguchi2021-12-256-154/+32
| | | | | | | We migrated to GitHub Actions for CI and they are no longer actively maintained. CONTRIBUTING.md is also updated to reflect the change.
* test/openssl/test_ssl: adjust certificate expiry dateKazuki Yamaguchi2021-12-251-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. (cherry picked from commit ruby/ruby@cd51bf61a2178a73219f7884792dfb82ca64c082)
* Merge pull request #457 from unasuke/ossl_bn_ractorKazuki Yamaguchi2021-12-222-1/+26
|\ | | | | Add test cases to OpenSSL::BN using ractor
| * Add tast cases to OpenSSL::BN using ractorYusuke Nakamura2021-12-212-1/+26
|/ | | | | | 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.
* Merge pull request #481 from rhenium/ky/openssl-3.0.0-part2Kazuki Yamaguchi2021-12-2010-65/+111
|\ | | | | Miscellaneous changes for OpenSSL 3.0 support (part 2)
| * .github/workflows: test against OpenSSL 3.0ky/openssl-3.0.0-part2Kazuki Yamaguchi2021-12-201-1/+2
| | | | | | | | | | Although OpenSSL 3.0 support is not complete yet, our test suite should now run on OpenSSL 3.0.1 too.
| * pkey: use EVP_PKEY_CTX_new_from_name() on OpenSSL 3.0Kazuki Yamaguchi2021-12-201-0/+6
| | | | | | | | | | Replace EVP_PKEY_CTX_new_id() with the new EVP_PKEY_CTX_new_from_name() which takes the algorithm name in a string instead of in an NID.
| * pkey: assume a pkey always has public key components on OpenSSL 3.0Kazuki Yamaguchi2021-12-201-0/+11
| | | | | | | | | | | | | | | | | | OpenSSL 3.0's EVP_PKEY_get0() returns NULL for provider-backed pkeys. This causes segfault because it was supposed to never return NULL before. We can't check the existence of public key components in this way on OpenSSL 3.0. Let's just skip it for now.
| * 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.
| * 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.
| * ssl: add constants for new SSL_OP_* flagsKazuki Yamaguchi2021-12-201-6/+29
| | | | | | | | | | Add all SSL_OP_* constants defined in OpenSSL 3.0.0 which are not specific to DTLS.
| * engine: disable OpenSSL::Engine on OpenSSL 3.0Kazuki Yamaguchi2021-12-204-7/+11
| | | | | | | | | | | | | | | | | | | | The entire ENGINE API is deprecated in OpenSSL 3.0 in favor of the new "Provider" concept. OpenSSL::Engine will not be defined when compiled with OpenSSL 3.0. We would need a way to interact with providers from Ruby programs, but since the concept is completely different from the ENGINE API, it will not be through the current OpenSSL::Engine interface.
| * 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.
| * hmac: fix wrong usage of EVP_DigestSignFinal()Kazuki Yamaguchi2021-12-201-2/+2
| | | | | | | | | | According to the manpage, the "siglen" parameter must be initialized beforehand.
| * 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.
* Merge pull request #480 from rhenium/ky/pkey-deprecate-modifyKazuki Yamaguchi2021-12-208-98/+221
|\ | | | | pkey: deprecate PKey::*#set_* and PKey::{DH,EC}#generate_key!
| * pkey: deprecate PKey#set_* methodsky/pkey-deprecate-modifyKazuki Yamaguchi2021-12-206-68/+149
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * pkey/ec: deprecate OpenSSL::PKey::EC#generate_key!Kazuki Yamaguchi2021-12-202-8/+17
| | | | | | | | | | | | 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.
| * pkey/dh: deprecate OpenSSL::PKey::DH#generate_key!Kazuki Yamaguchi2021-12-203-16/+34
| | | | | | | | | | | | 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.
| * pkey/ec: avoid using EC#public_key= in EC#dh_compute_keyKazuki Yamaguchi2021-12-171-3/+8
| | | | | | | | | | | | Similarly to DH#compute_key, work around it by constructing a SubjectPublicKeyInfo. This should be considered as a temporary implementation.
| * pkey/dh: avoid using DH#set_key in DH#compute_keyKazuki Yamaguchi2021-12-171-3/+13
| | | | | | | | | | | | | | | | | | | | DH#set_key will not work on OpenSSL 3.0 because keys are immutable. For now, let's reimplement DH#compute_key by manually constructing a DER-encoded SubjectPublicKeyInfo structure and feeding it to OpenSSL::PKey.read. Eventually, we should implement a new method around EVP_PKEY_fromdata() and use it instead.
* | Merge pull request #478 from rhenium/ky/pkey-base-dupKazuki Yamaguchi2021-12-127-169/+262
|\ \ | | | | | | pkey: allocate EVP_PKEY on #initialize
| * | pkey: use EVP_PKEY_dup() if availableky/pkey-base-dupKazuki Yamaguchi2021-12-126-1/+42
| | | | | | | | | | | | | | | We can use it to implement OpenSSL::PKey::PKey#initialize_copy. This should work on all key types, not just DH/DSA/EC/RSA types.
| * | pkey: allocate EVP_PKEY on #initializeKazuki Yamaguchi2021-12-126-163/+218
| | | | | | | | | | | | | | | | | | | | | Allocate an EVP_PKEY when the content is ready: when #initialize or #initialize_copy is called, rather than when a T_DATA is allocated. This is more natural because the lower level API has been deprecated and an EVP_PKEY is becoming the minimum unit of handling keys.
| * | pkey: do not check NULL argument in ossl_pkey_new()Kazuki Yamaguchi2021-12-122-5/+2
| |/ | | | | | | | | Passing NULL to ossl_pkey_new() makes no sense in the first place, and in fact it is ensured not to be NULL in all cases.
* | Merge pull request #479 from rhenium/ky/pkey-ossl-decoderKazuki Yamaguchi2021-12-122-0/+46
|\ \ | |/ |/| pkey: use OSSL_DECODER to load encrypted PEM on OpenSSL 3.0
| * pkey: use OSSL_DECODER to load encrypted PEM on OpenSSL 3.0ky/pkey-ossl-decoderKazuki Yamaguchi2021-12-121-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | OpenSSL 3.0 has rewritten routines to load pkeys (PEM_read_bio_* and d2i_* functions) around the newly introduced OSSL_DECODER API. This comes with a slight behavior change. They now decrypt and parse each encountered PEM block, then check the kind of the block. This used to be the reverse: they checked the PEM header to see the kind, and then decrypted the content. This means that the password callback may now be called repeatedly. Let's use the OSSL_DECODER API directly on OpenSSL 3.0 so that the return value from the password callback will be reused automatically.
| * pkey: test parsing concatenated PEM stringKazuki Yamaguchi2021-12-121-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.
* Merge pull request #472 from ruby/typoKazuki Yamaguchi2021-11-033-3/+3
|\ | | | | Fix typos [ci skip]
| * Fix typos [ci skip]Nobuyoshi Nakada2021-11-033-3/+3
|/
* Merge pull request #469 from rhenium/ky/ssl-unstarted-ioKazuki Yamaguchi2021-11-012-190/+104
|\ | | | | ssl: disallow reading/writing to unstarted SSL socket
| * ssl: disallow reading/writing to unstarted SSL socketky/ssl-unstarted-ioKazuki Yamaguchi2021-10-252-190/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | x509name: improve docs for X509::NameKazuki Yamaguchi2021-11-012-2/+27
| | | | | | | | | | | | | | | | | | | | Add docs for X509::Name.parse_openssl and X509::Name.parse_rfc2253, which are currently undocumented despite being widely used. Small changes are also made to #to_s and the class description to recommend using RFC 2253-based methods. Fixes: https://github.com/ruby/openssl/issues/470
* | Merge pull request #468 from rhenium/ky/openssl-3.0.0-part1Kazuki Yamaguchi2021-10-2512-150/+168
|\ \ | |/ |/| Miscellaneous changes for OpenSSL 3.0 support
| * bn: expand BIGNUM_RAND and BIGNUM_RAND_RANGE macrosky/openssl-3.0.0-part1Kazuki Yamaguchi2021-10-241-50/+50
| | | | | | | | | | Now that BN.pseudo_rand{,_range} are alias, those macros are only used once. Let's expand the macros for better readability.
| * bn: make BN.pseudo_rand{,_range} an alias of BN.rand{,_range}Kazuki Yamaguchi2021-10-242-16/+6
| | | | | | | | | | | | 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.
| * pkey, ssl: use EVP_PKEY_eq() instead of EVP_PKEY_cmp()Kazuki Yamaguchi2021-10-244-3/+8
| | | | | | | | | | OpenSSL 3.0 renamed EVP_PKEY_cmp() to EVP_PKEY_eq() because that was a confusing name.
| * pkey/ec: use EC_GROUP_free() instead of EC_GROUP_clear_free()Kazuki Yamaguchi2021-10-241-1/+1
| | | | | | | | | | | | | | EC_GROUP_clear_free() is deprecated in OpenSSL 3.0. EC_GROUP does not include any sensitive data, so we can safely use EC_GROUP_free() instead.
| * pkey/ec: deprecate PKey::EC::Point#make_affine! and make it a no-opKazuki Yamaguchi2021-10-241-0/+5
| | | | | | | | | | | | | | | | | | It converts the internal representation of the point object to the affine coordinate system. However, it had no real use case because the difference in the internal representation has not been visible from Ruby/OpenSSL at all. EC_POINT_make_affine() is marked as deprecated in OpenSSL 3.0.
| * hmac: use EVP_MD_CTX_get_pkey_ctx() instead of EVP_MD_CTX_pkey_ctx()Kazuki Yamaguchi2021-10-243-5/+14
| | | | | | | | | | | | OpenSSL 3.0 renamed EVP_MD_CTX_pkey_ctx() to include "get" in the function name. Adjust compatibility macro so that we can use the new function name for all OpenSSL 1.0.2-3.0.
| * digest: use EVP_MD_CTX_get0_md() instead of EVP_MD_CTX_md() if existsKazuki Yamaguchi2021-10-244-4/+9
| | | | | | | | | | | | | | | | | | | | The function was renamed in OpenSSL 3.0 due to the change of the lifetime of EVP_MD objects. They are no longer necessarily statically allocated and can be reference-counted -- when an EVP_MD_CTX is free'd, the associated EVP_MD can also become inaccessible. Currently Ruby/OpenSSL only handles builtin algorithms, so no special handling is needed except for adapting to the rename.
| * bn: use BN_check_prime() in OpenSSL::BN#prime{,_fasttest}?Kazuki Yamaguchi2021-10-242-49/+22
| | | | | | | | | | In OpenSSL 3.0, BN_is_prime_ex() and BN_is_prime_fasttest_ex() are deprecated in favor of BN_check_prime().
| * ssl: use SSL_get_rbio() to check if SSL is started or notKazuki Yamaguchi2021-10-241-2/+2
| | | | | | | | | | | | | | | | Use SSL_get_rbio() instead of SSL_get_fd(). SSL_get_fd() internally calls SSL_get_rbio() and it's enough for our purpose. In OpenSSL 3.0, SSL_get_fd() leaves an entry in the OpenSSL error queue if BIO has not been set up yet, and we would have to clean it up.
| * ssl: use SSL_CTX_load_verify_{file,dir}() if availableKazuki Yamaguchi2021-10-242-0/+8
| | | | | | | | | | SSL_CTX_load_verify_locations() is deprecated in OpenSSL 3.0 and replaced with those two separate functions. Use them if they exist.