1253 Commits
Author SHA1 Message Date
Kazuki Yamaguchi cd38f6c5e1 Merge openssl-4.0.2
The changes can be found at:

    https://github.com/ruby/openssl/compare/v4.0.1...v4.0.2
2026-05-13 15:01:28 -07:00
Kazuki Yamaguchi 729e1512df Merge openssl-4.0.1
The changes can be found at:

    https://github.com/ruby/openssl/compare/v4.0.0...v4.0.1
2026-05-13 15:01:28 -07:00
Kazuki Yamaguchi f079373185 [ruby/openssl] Ruby/OpenSSL 4.0.0
https://github.com/ruby/openssl/commit/5af1edab18
2025-12-15 09:50:30 +00:00
Kazuki Yamaguchi f06eb75646 [ruby/openssl] ossl.c: improve docs for constants and methods under ::OpenSSL
https://github.com/ruby/openssl/commit/b0de8ba9bd
2025-12-15 09:09:49 +00:00
Kazuki Yamaguchi ee6ba41bfd [ruby/openssl] Freeze more constants for Ractor compatibility
https://github.com/ruby/openssl/commit/695126f582
2025-12-15 09:09:49 +00:00
Kazuki Yamaguchi 674c3d73e0 [ruby/openssl] pkcs7: raise OpenSSL::PKCS7::PKCS7Error in #initialize
When d2i_PKCS7_bio() and PEM_read_bio_PKCS7() fail to decode the input,
OpenSSL::PKCS7.new currently raises ArgumentError. The usual practice
in ruby/openssl where an error originates from the underlying OpenSSL
library is to raise OpenSSL::OpenSSLError.

Raise OpenSSL::PKCS7::PKCS7Error instead for consistency with
OpenSSL::PKCS7.read_smime and all other existing #initialize methods
that handle DER/PEM-encoded inputs.

https://github.com/ruby/openssl/commit/67a608ce53
2025-12-14 10:46:27 +00:00
Kazuki Yamaguchi 7969b65418 [ruby/openssl] x509cert: update doc for OpenSSL::X509::Certificate#==
Mention the underlying OpenSSL function. Add a note about the unreliable
comparison when called on an incomplete object.

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

https://github.com/ruby/openssl/commit/736af5b3c7
2025-12-14 10:46:13 +00:00
Kazuki Yamaguchi e8d32dddc0 [ruby/openssl] ossl.c: implement OpenSSL::OpenSSLError#detailed_message
An OpenSSL function sometimes puts more than one error entry into the
thread-local OpenSSL error queue. Currently, we use the highest-level
entry for generating the exception message and discard the rest.

Let ossl_make_error() capture all current OpenSSL error queue contents
into OpenSSL::OpenSSLError#errors and extend
OpenSSL::OpenSSLError#detailed_message to include the information.

An example:

    $ ruby -Ilib -ropenssl -e'OpenSSL::X509::ExtensionFactory.new.create_ext("a", "b")'
    -e:1:in 'OpenSSL::X509::ExtensionFactory#create_ext': a = b: error in extension (name=a, value=b) (OpenSSL::X509::ExtensionError)
    OpenSSL error queue reported 2 errors:
    error:11000082:X509 V3 routines:do_ext_nconf:unknown extension name
    error:11000080:X509 V3 routines:X509V3_EXT_nconf_int:error in extension (name=a, value=b)
            from -e:1:in '<main>'

https://github.com/ruby/openssl/commit/d28f7a9a13
2025-12-13 16:57:53 +00:00
Theo Buehler 47c0dae188 [ruby/openssl] asn1integer_to_num: don't cast away const
ASN1_ENUMERATED_to_BN() has been const-correct for a long time in all
supported libcrytos, so we can remove this workaround.

https://github.com/ruby/openssl/commit/d0f36a7c65
2025-12-06 17:26:32 +00:00
Theo Buehler 8d3da814c0 [ruby/openssl] Convert ossl_x509ext.c to opaque ASN1_STRING
https://github.com/ruby/openssl/commit/a41cf28bab
2025-12-06 16:50:17 +00:00
Theo Buehler 38ad0806d7 [ruby/openssl] Convert ossl_ts.c to opaque ASN1_STRING
https://github.com/ruby/openssl/commit/8945f379b3
2025-12-06 16:50:17 +00:00
Theo Buehler a07997bf81 [ruby/openssl] Convert ossl_ns_spki.c to opaque ASN1_STRING
https://github.com/ruby/openssl/commit/0941ebbda5
2025-12-06 16:50:17 +00:00
Theo Buehler 98c151b0e5 [ruby/openssl] Convert some of ossl_asn1.c to opaque ASN1_STRING
This uses the normal accessors but leaves out BIT STRINGS, which will
need compat implementations for ASN1_BIT_STRING_get_length() and
ASN1_BIT_STRING_set1() for older libcryptos.

https://github.com/openssl/openssl/issues/29184
https://github.com/openssl/openssl/issues/29185

https://github.com/ruby/openssl/commit/ba3d1cc5c2
2025-12-06 16:50:16 +00:00
Theo Buehler d3aa7b889f [ruby/openssl] Convert ossl_ocsp.c to opaque ASN1_STRING
OpenSSL plans to make asn1_string_st opaque, the struct underlying most
ASN.1 types such as ASN1_*STRING, ASN1_ENUMERATED, ASN1_INTEGER, etc.
Most of ruby/openssl's C code can be straigtforwardly converted to use
accessors available since OpenSS

https://github.com/ruby/openssl/commit/374262435a
2025-12-06 16:50:16 +00:00
Theo Buehler 9dfb7bd7d4 [ruby/openssl] const correct ossl_bin2hex()
This helper only reads from its in parameter. Making that const
avoids a couple of casts in an upcoming change.

https://github.com/ruby/openssl/commit/970d5764e3
2025-12-06 16:50:16 +00:00
Kazuki Yamaguchi 8c4f79d5f3 [ruby/openssl] x509cert: handle invalid validity periods in Certificate#inspect
In a newly allocated OpenSSL X509 object, the notBefore and notAfter
fields contain an ASN1_STRING object with type V_ASN1_UNDEF rather than
an ASN1_TIME.

Commit https://github.com/ruby/openssl/commit/73484f67949a made asn1time_to_time() stricter and it now raises
an exception if the argument is not an ASN1_TIME. Previously, it would
print a verbose-mode warning and return nil.

OpenSSL::X509::Certificate#inspect should work even when the certificate
is invalid. Let's handle this.

https://github.com/ruby/openssl/commit/18c283f2b6
2025-12-05 18:40:02 +00:00
Kazuki Yamaguchi f179885d3c [ruby/openssl] asn1: use ASN1_TIME_to_tm() to decode UTCTime and GeneralizedTime
The current logic relies on sscanf() and error checks are almost
entirely missing. It also assumes that ASN1_STRING contents are NUL
terminated, which is undocumented and not guaranteed for all valid
ASN1_TIME objects.

Switch to using ASN1_TIME_to_tm() added in OpenSSL 1.1.1. It is also
supported by LibreSSL and AWS-LC.

In the long term, we may want to replace ASN1_TIME_to_tm() with a
hand-rolled decoder, since the function is intended for a specific
use-case. It is too permissive for strict DER, yet still does not
support all valid DER inputs and silently drops information such as
fractional seconds. However, it handles everything that the current
sscanf() code could handle.

https://github.com/ruby/openssl/commit/73484f6794
2025-12-05 12:24:54 +00:00
Kazuki Yamaguchi bf2b9c0947 [ruby/openssl] asn1: reorder declarations
Move variable declarations for OpenSSL::ASN1 classes to the top of the
file. asn1time_to_time() will need eASN1Error in the next patch.

https://github.com/ruby/openssl/commit/6c0ef87897
2025-12-05 12:24:54 +00:00
Kazuki Yamaguchi 5062c0c621 [ruby/openssl] Expand tabs in C source files
Since around 2018, we have been using spaces for indentation for newly
added code[1]. The mixed use of tabs and spaces has repeatedly confused
new contributors who configured their editors to use a different tab
size than 8. Since git blame can now skip specific commits, ruby/ruby
did a mass reformatting of tabs in 2022[2]. Do the same in ruby/openssl.

While at it, fix a few indentation issues, mainly in switch-case labels
and in ossl_ssl_session.c, which used doubled indentation size.

This patch contains white-space changes only. git diff -w output should
be empty.

[1] https://bugs.ruby-lang.org/issues/14246
[2] https://bugs.ruby-lang.org/issues/18891

https://github.com/ruby/openssl/commit/4d6214f507
2025-12-04 17:46:59 +00:00
Kazuki Yamaguchi 6fe1c15911 [ruby/openssl] Revert "rewriting most of the asn1 init code in ruby"
This reverts commit https://github.com/ruby/openssl/commit/830505172882.

The commit is part of the bigger effort to rewrite OpenSSL::ASN1 in
Ruby. OpenSSL::ASN1 is relatively isolated from the rest of ruby/openssl
and is not tightly bound to the OpenSSL API. The current implementation
also needs a major refactor for several reasons, so this remains a
long-term goal.

However, the work is not yet complete. We are close to releasing v4.0.0,
and we want to avoid shipping fragmented code in a stable branch. The
changes can be reapplied when the rest is ready.

https://github.com/ruby/openssl/commit/362942dcbf
2025-12-04 17:32:37 +00:00
Kazuki Yamaguchi bae06ce22c [ruby/openssl] Remove dummy declarations for mOSSL and eOSSLError
These declarations were added to every source file because older
versions of RDoc did not resolve ancestor tree across files. Since
RDoc 6.9.0 supports this, this workaround is no longer needed.

    https://redirect.github.com/ruby/rdoc/pull/1217

https://github.com/ruby/openssl/commit/6491ce63be
2025-11-29 17:05:19 +00:00
Kazuki Yamaguchi c8bfbd5700 [ruby/openssl] ts: fix docs for attrs on OpenSSL::Timestamp::Factory
Move attribute documentation out of the class-level section and into
the appropriate sections so that they attach correctly.

https://github.com/ruby/openssl/commit/61410acc50
2025-11-29 16:41:54 +00:00
Kazuki Yamaguchi dd489ee9c4 [ruby/openssl] asn1: refactor converting ASN1_OBJECT to string
ruby/openssl exposes OIDs to Ruby as strings in many places, but the
conversion logic has been duplicated and the behavior is inconsistent.
There are mainly two patterns:

 - Returns the short name associated with the OID/NID, or the dotted
   decimal notation if it is unknown to OpenSSL.
 - Returns the long name, or the dotted decimal notation.

These patterns are implemented using different OpenSSL APIs and that
caused subtle differences. Add helper functions ossl_asn1obj_to_string()
and ossl_asn1obj_to_string_long_name() to unify the logic.

Also, document the current behaviors where it is not yet done. The
inconsistency was likely unintentional, but since it dates back to the
original implementations, standardizing it now would cause more issues
than it resolves.

https://github.com/ruby/openssl/commit/2ea36c21a4
2025-11-22 16:48:13 +00:00
Kazuki Yamaguchi 424499dd10 [ruby/openssl] ts: refactor converting string to ASN1_OBJECT
obj_to_asn1obj() in ossl_ts.c and ossl_asn1.c are identical. Let's
remove one in ossl_ts.c.

eASN1Error can now be made static to ossl_asn1.c.

https://github.com/ruby/openssl/commit/dcb05c40c2
2025-11-22 16:48:13 +00:00
Kazuki Yamaguchi f9efa0cc04 [ruby/openssl] pkey/ec: fix OpenSSL::PKey::EC::Group#curve_name for unknown curves
EC_GROUP_get_curve_name() returns NID_undef when OpenSSL does not
recognize the curve and there is no associated OID.

Handle this case explicitly and return nil instead of the string
"UNDEF", which should not be exposed outside the extension.

https://github.com/ruby/openssl/commit/2c16821c07
2025-11-22 14:25:15 +00:00
Kazuki Yamaguchi 87ae631b40 [ruby/openssl] pkey/rsa: fix usage of eRSAError
This is a follow-up to commit https://github.com/ruby/openssl/commit/e74ff3e2722f, which missed the line added
in a different PR.

https://github.com/ruby/openssl/commit/1b01d19456
2025-11-06 13:40:55 +00:00
Kazuki Yamaguchi 16b1aa4e4a [ruby/openssl] pkey: unify error classes into PKeyError
Remove the following subclasses of OpenSSL::PKey::PKeyError and make
them aliases of it.

 - OpenSSL::PKey::DHError
 - OpenSSL::PKey::DSAError
 - OpenSSL::PKey::ECError
 - OpenSSL::PKey::RSAError

Historically, methods defined on OpenSSL::PKey and OpenSSL::PKey::PKey
raise OpenSSL::PKey::PKeyError, while methods on the subclasses raise
their respective exception classes. However, this distinction is not
particularly useful since all those exception classes represent the
same kind of errors from the underlying EVP_PKEY API.

I think this convention comes from the fact that OpenSSL::PKey::{DH,
DSA,RSA} originally wrapped the corresponding OpenSSL structs DH, DSA,
and RSA, before they were unified to wrap EVP_PKEY, way back in 2002.

OpenSSL::PKey::EC::Group::Error and OpenSSL::PKey::EC::Point::Error
are out of scope of this change, as they are not subclasses of
OpenSSL::PKey::PKeyError and do not represent errors from the EVP_PKEY
API.

https://github.com/ruby/openssl/commit/e74ff3e272
2025-11-06 13:33:15 +00:00
Kazuki Yamaguchi 57aaf86bdb [ruby/openssl] cipher: use EVP_CIPHER_fetch() if available
Likewise, use EVP_MD_fetch() if it is available.

This adds support for AES-GCM-SIV with OpenSSL 3.2 or later.

https://github.com/ruby/openssl/commit/0e565a215e
2025-11-06 13:25:09 +00:00
Kazuki Yamaguchi 10d2311e13 [ruby/openssl] digest: use EVP_MD_fetch() if available
With the introduction of OpenSSL 3 providers, newly implemented
algorithms do not necessarily have a corresponding NID assigned. To use
such an algorithm, it has to be "fetched" from providers using the new
EVP_*_fetch() functions.

For digest algorithms, we have to use EVP_MD_fetch() instead of the
existing EVP_get_digestbyname(). However, it is not a drop-in
replacement because:

 - EVP_MD_fetch() does not support all algorithm name aliases recognized
   by EVP_get_digestbyname().

 - Both return an EVP_MD, but the one returned by EVP_MD_fetch() is
   sometimes reference counted and the user has to explicitly release
   it with EVP_MD_free().

So, keep using EVP_get_digestbyname() for all OpenSSL versions for now,
and fall back to EVP_MD_fetch() if it fails. In the latter case, prepare
a T_DATA object to manage the fetched EVP_MD's lifetime.

https://github.com/ruby/openssl/commit/9fc2179403
2025-11-06 13:25:09 +00:00
Kazuki Yamaguchi 26751e4085 [ruby/openssl] cipher: raise CipherError for unsupported algorithm name
Raise OpenSSL::Cipher::CipherError instead of ArgumentError or
RuntimeError for consistency.

https://github.com/ruby/openssl/commit/78601c9c34
2025-11-06 13:25:09 +00:00
Kazuki Yamaguchi 18ab5023b6 [ruby/openssl] digest: raise DigestError for unsupported algorithm name
We generally raise OpenSSL::OpenSSLError or its subclass for errors
originating from the OpenSSL library, which may include extra details
appended by ossl_raise().

https://github.com/ruby/openssl/commit/9427a05ce5
2025-11-06 13:25:09 +00:00
Kazuki Yamaguchi e5ac2b8956 [ruby/openssl] cipher: various docs improvements
The EVP_CIPHER_CTX = OpenSSL::Cipher interface for AEAD ciphers is
notoriously complicated and full of pitfalls. I tried to clarify docs
so that users can hopefully connect the Ruby methods with the
corresponding OpenSSL man pages more easily.

- Call out the common mistakes with Cipher#iv= and Cipher#auth_tag=
  with AES-GCM.
- Update outdated notes about the method calling order requirements
  with AEAD ciphers.
- Add references to the man page where the behavior varies according to
  the specific cipher algorithm and we cannot document every detail.
- Various style/wording updates.

https://github.com/ruby/openssl/commit/30e22d9bbb
2025-10-27 06:54:01 +00:00
Kazuki Yamaguchi ecf5aa18ca [ruby/openssl] Sync History.md 2025-10-27 15:36:25 +09:00
Stan Hu b839deec49 [ruby/openssl] Check NULL values for deprecated EVP_PKEY_get0() functions
In OpenSSL <= 1.1.1, EVP_PKEY_get0() always returned a valid object, so
a NULL check was not necessary. In OpenSSL 3.0, the function can return
NULL (https://docs.openssl.org/3.0/man7/migration_guide/#deprecated-function-mappings),
so guard against this issue.

https://github.com/ruby/openssl/commit/dc90b9c51e
2025-10-27 15:33:17 +09:00
Tobias Haar f6d2aef3ec [ruby/openssl] Update link to OpenSSL configuration file docs
https://github.com/ruby/openssl/commit/02ff964114
2025-10-27 05:51:18 +00:00
Kazuki Yamaguchi a8b34d9a9b [ruby/openssl] ssl: allow SSLContext#set_params to be used from non-main Ractors
Freeze OpenSSL::SSL::SSLContext::DEFAULT_PARAMS so that it becomes
Ractor-shareable.

Also, prepare a new OpenSSL::X509::Store in Ractor-local storage, if
called from a non-main Ractor. OpenSSL::X509::Store currently is not a
shareable object.

https://github.com/ruby/openssl/commit/3d5271327c
2025-10-08 14:27:16 +00:00
Kazuki Yamaguchi e4f1280831 [ruby/openssl] ssl: refactor tmp_dh_callback handling
tmp_dh_callback no longer has a default value. It also no longer has to
share code with tmp_ecdh_callback, which has been removed in v3.0.0.

https://github.com/ruby/openssl/commit/b7cde6df2a
2025-10-08 13:59:39 +00:00
Kazuki Yamaguchi ea79fe225c [ruby/openssl] ssl: use SSL_CTX_set_dh_auto() by default
Rely on OpenSSL's builtin DH parameters for TLS 1.2 and earlier instead
of providing a default SSLContext#tmp_dh_callback proc.
SSL_CTX_set_dh_auto() has been available since OpenSSL 1.1.0.

The parameters can still be overridden by specifying
SSLContext#tmp_dh_callback or #tmp_dh, as confirmed by existing tests.

SSLContext#tmp_dh_callback depends on a deprecated OpenSSL feature. We
also prefer not to hard-code parameters, which is a maintenance burden.
This change also improves Ractor compatibility by removing the
unshareable proc.

https://github.com/ruby/openssl/commit/9cfec9bf5e
2025-10-08 13:59:39 +00:00
Kazuki Yamaguchi 8dfe540341 [ruby/openssl] ssl: fix extconf.rb check for SSL_CTX_set0_tmp_dh_pkey()
Check for the function we actually use. Both SSL_set0_tmp_dh_pkey() and
SSL_CTX_set0_tmp_dh_pkey() were added in OpenSSL 3.0.

https://github.com/ruby/openssl/commit/a9b6a64e5f
2025-10-08 13:59:38 +00:00
Kazuki Yamaguchi 33808e0f7c [ruby/openssl] Bump version number to 4.0.0.pre
https://github.com/ruby/openssl/commit/64f4aae6bd
2025-10-06 17:02:44 +09:00
Kazuki Yamaguchi 224c17876c [ruby/openssl] Ruby/OpenSSL 3.3.1
https://github.com/ruby/openssl/commit/2b88a6d444
2025-10-06 16:56:55 +09:00
Kazuki Yamaguchi 7863389ad0 [ruby/openssl] ssl: remove OpenSSL::X509::V_FLAG_CRL_CHECK_ALL from the default store
With OpenSSL 3.6.0, it causes nearly every certificate verification to
fail with the message "certificate verify failed (unable to get
certificate CRL)" because the CRLs are typically unavailable in the
default store used by OpenSSL::SSL::SSLContext#set_params.

OpenSSL::X509::V_FLAG_CRL_CHECK_ALL is a flag that extends the CRL
checking to all certificates in the chain. In OpenSSL < 3.6.0, the flag
alone has no effect, and OpenSSL::X509::V_FLAG_CRL_CHECK must also be
set to enable CRL checking.

In OpenSSL 3.6.0, OpenSSL::X509::V_FLAG_CRL_CHECK_ALL now implies
OpenSSL::X509::V_FLAG_CRL_CHECK. This is inconsistent with the man page
and may be fixed in a future OpenSSL 3.6.x release, but this flag is not
needed and should not be set by default.

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

https://github.com/ruby/openssl/commit/e8481cd687
2025-10-06 16:55:14 +09:00
Kazuki Yamaguchi ad35a4be82 [ruby/openssl] pkey: disallow {DH,DSA,EC,RSA}.new without arguments with OpenSSL 3.0
Raise ArgumentError if this is attempted when the extension is compiled
with OpenSSL 3.0 or later. The form will be fully removed when we drop
support for OpenSSL 1.1.1.

When OpenSSL::PKey::{DH,DSA,EC,RSA}.new is called without any arguments,
it sets up an empty corresponding low-level struct and wraps it in an
EVP_PKEY. This is useful when the user later fills the missing fields
using low-level setter methods such as OpenSSL::PKey::RSA#set_key.

Such setter methods are not compatible with OpenSSL 3.0 or later, where
EVP_PKEY is immutable once created. This means that the ability to
create an empty instance is useless.

https://github.com/ruby/openssl/commit/affd569f78
2025-09-30 11:59:28 +00:00
Kazuki Yamaguchi 986d9177dd [ruby/openssl] pkey: define and use OSSL_HAVE_IMMUTABLE_PKEY macro
Introduce a useful macro indicating that the low-level struct wrapped
in an EVP_PKEY cannot be modified.

Currently, the macro is defined for OpenSSL 3.0 or later only. LibreSSL
and AWS-LC can follow suit in the future.

https://github.com/ruby/openssl/commit/032ed63096
2025-09-30 11:59:27 +00:00
Samuel Williams a1f39b4b80 [ruby/openssl] Add AuthTagError exception for AEAD authentication
failures
(https://github.com/ruby/openssl/pull/939)

* Add AuthTagError exception for AEAD authentication failures

- Add OpenSSL::Cipher::AuthTagError as a subclass of CipherError
- Raise AuthTagError specifically for AEAD cipher authentication tag verification failures
- Enhanced error messages: 'AEAD authentication tag verification failed' for auth failures
- Precise detection: Only EVP_CipherFinal_ex failures in AEAD ciphers raise AuthTagError
- All other errors (key setup, IV setup, update failures, etc.) still raise CipherError
- Comprehensive test coverage for GCM/CCM modes and error inheritance
- Fully backwards compatible: AuthTagError < CipherError

https://github.com/ruby/openssl/commit/9663b09040
2025-09-17 12:32:50 +00:00
Kazuki Yamaguchi 08e7b5f2bd [ruby/openssl] Revert "pkey: stop retrying after non-retryable error from OSSL_DECODER"
This reverts commit https://github.com/ruby/openssl/commit/5347880c6eb0 and
https://github.com/ruby/openssl/commit/985ba27d6339.

These commits attempted to stop processing after the first relevant PEM
block, whether it is successful or not, when the input contains multiple
keys.

It turned out that it cannot be reliably determined using the
OSSL_DECODER API. There is an edge case where OSSL_DECODER_from_bio()
reports "unsupported" even though the input actually contains an error:

https://redirect.github.com/ruby/openssl/pull/931#discussion_r2347813807

Revert the changes for now and keep the existing behavior, as partial
support does not seem worth the added complexity.

https://github.com/ruby/openssl/commit/319cd4952a
2025-09-17 12:18:17 +00:00
Kazuki Yamaguchi 8a30594d2c [ruby/openssl] pkey: fix loading public keys with early OpenSSL 3.0.x releases
Treat an empty error queue after calling OSSL_DECODER_from_bio() as a
retryable error.

This is a follow-up to the previous commit https://github.com/ruby/openssl/commit/985ba27d6339 (pkey: stop
retrying after non-retryable error from OSSL_DECODER). The commit broke
loading public keys on Ubuntu 22.04 LTS, which ships OpenSSL 3.0.2.

https://github.com/ruby/openssl/commit/5347880c6e
2025-09-12 14:22:29 +00:00
Kazuki Yamaguchi c082005824 [ruby/openssl] pkey: stop retrying after non-retryable error from OSSL_DECODER
Continue processing only when OSSL_DECODER_from_bio() returns the error
code ERR_R_UNSUPPORTED. Otherwise, raise an exception without retrying
decoding the input in another format.

This fixes another case where OpenSSL::PKey.read prompts for a
passphrase multiple times when the input contains multiple
passphrase-protected PEM blocks and the first one cannot be decoded.

I am not entirely sure if the error code ERR_R_UNSUPPORTED is considered
part of the public interface of OpenSSL, but this seems to be the only
option available and is the approach used internally by the
PEM_read_bio_*() functions.

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

https://github.com/ruby/openssl/commit/985ba27d63
2025-09-12 12:26:07 +00:00
Kazuki Yamaguchi 8af8582d4c [ruby/openssl] pkey: pass pem_password_cb to OSSL_DECODER only when it is needed
Specify OSSL_DECODER_CTX_set_pem_password_cb() only when we expect a
passphrase-protected private key.

OSSL_DECODER appears to try to decrypt every PEM block in the input even
when the PEM header does not match the requested selection. This can
cause repeated prompts for a passphrase in a single OpenSSL::PKey.read
call.

https://github.com/ruby/openssl/commit/933503f49f
2025-09-12 12:26:07 +00:00
John Hawthorn 3ff1ca07ba [ruby/openssl] Add missing write barriers in X509
Both the X509 store and X509 store context were missing write barriers.
To the callback object being stored in the ex data.

These values were also being stored as an IV, however in Ruby HEAD we're
now storing the IVs for T_DATA (generic IVs) on a separate object. So we
need an additional write barrier.

I believe this was always necessary, because we could have done
incremental marking ahead of compaction, and without the write barrier
the mark function could have been run before @verify_callback was
assigned.

This was detected by wbcheck

https://github.com/ruby/openssl/commit/1fda3a99ef
2025-08-19 16:30:50 +00:00