Skip to content

Include "additional data" message in OpenSSL errors#648

Merged
rhenium merged 2 commits intoruby:masterfrom
rhenium:ky/error-additional-data
Aug 16, 2023
Merged

Include "additional data" message in OpenSSL errors#648
rhenium merged 2 commits intoruby:masterfrom
rhenium:ky/error-additional-data

Conversation

@rhenium
Copy link
Member

@rhenium rhenium commented Jul 1, 2023

Error entries in the OpenSSL error queue may contain additional contextual information associated with the error, which can be helpful when debugging.

This "additional data" is currently only printed to stderr when OpenSSL.debug is enabled. Let's include this in the exception messages raised with ossl_raise(), too.

$ ruby -Ilib -ropenssl -e'OpenSSL.debug=true; OpenSSL::SSL::SSLContext.new.ecdh_curves="P-256:not-a-curve"'
-e:1: warning: error on stack: error:0A080106:SSL routines:gid_cb:passed invalid argument (group 'not-a-curve' cannot be set)
-e:1:in `ecdh_curves=': passed invalid argument (group 'not-a-curve' cannot be set) (OpenSSL::SSL::SSLError)
	from -e:1:in `<main>'

@rhenium rhenium changed the title Ky/error additional data Include "additional data" message in OpenSSL errors Jul 1, 2023
Test that the error message contains the necessary text instead of the
exact match. Exceptions raised by ossl_raise() may carry additional
context information in the message.
Error entries in the OpenSSL error queue may contain additional
contextual information associated with the error, which can be helpful
when debugging.

This "additional data" is currently only printed to stderr when
OpenSSL.debug is enabled. Let's include this in the exception messages
raised with ossl_raise(), too.

	$ ruby -Ilib -ropenssl -e'OpenSSL.debug=true; OpenSSL::SSL::SSLContext.new.ecdh_curves="P-256:not-a-curve"'
	-e:1: warning: error on stack: error:0A080106:SSL routines:gid_cb:passed invalid argument (group 'not-a-curve' cannot be set)
	-e:1:in `ecdh_curves=': passed invalid argument (group 'not-a-curve' cannot be set) (OpenSSL::SSL::SSLError)
		from -e:1:in `<main>'
@rhenium rhenium force-pushed the ky/error-additional-data branch from 0b44ad4 to 1c5bbdd Compare August 10, 2023 17:16
@junaruga
Copy link
Member

I really like this feature. Thank you! I was just trying to print additional errors by the ERR_print_errors_fp(stderr); today.

@rhenium rhenium merged commit 3f45150 into ruby:master Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants