Preserve OpenSSL exception in TS validation error path#483
Closed
klemensn wants to merge 1 commit intoopen-eid:masterfrom
Closed
Preserve OpenSSL exception in TS validation error path#483klemensn wants to merge 1 commit intoopen-eid:masterfrom
klemensn wants to merge 1 commit intoopen-eid:masterfrom
Conversation
if `TS_RESP_verify_token()` fails, ERR_get_error(3) is used to check for
a specific error reason and throw a specific exception.
But in case of different reasons, the generic `THROW_OPENSSLEXCEPTION()`
is used which itself ERR_get_error(3), at which point the actual error
has already been removed from the thread's error queue.
Use ERR_peek_error(3) for special casing the specific error instead,
such that the queue remains unmodified and `THROW_OPENSSLEXCEPTION()` is
able to show the actual error.
This results in the following error diff in case of TS valdiation errors
(as can be seen on OpenBSD when built LibreSSL):
```
$ digidoc-tool create --file=./hello.txt ./hello.asice
Version
digidoc-tool version: 3.14.8.0
libdigidocpp version: 3.14.8.0
Available certificates:
label: NANNI,KLEMENS ANTONIUS,39311290189
Selected:
label: NANNI,KLEMENS ANTONIUS,39311290189
Validation: �[31mFAILED�[0m
Exception:
SignatureXAdES_LTA.cpp:203 code(General) Signature validation
TS.cpp:288 code(General) Failed to verify TS response.
```
With this diff, the following line will be added at the end:
```
time stamp routines:0 code(General) error:2FFFF065:time stamp routines:CRYPTO_internal:ess signing certificate error
```
Signed-off-by: Klemens Nanni <klemens@posteo.de>
Contributor
Contributor
Author
|
I see, here's the output with #483 dropped and #481 applied instead (still using LibreSSL, of course): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
if
TS_RESP_verify_token()fails, ERR_get_error(3) is used to check fora specific error reason and throw a specific exception.
But in case of different reasons, the generic
THROW_OPENSSLEXCEPTION()is used which itself ERR_get_error(3), at which point the actual error
has already been removed from the thread's error queue.
Use ERR_peek_error(3) for special casing the specific error instead,
such that the queue remains unmodified and
THROW_OPENSSLEXCEPTION()isable to show the actual error.
This results in the following error diff in case of TS valdiation errors
(as can be seen on OpenBSD when built LibreSSL):
With this diff, the following line will be added at the end:
Signed-off-by: Klemens Nanni klemens@posteo.de
See #482 (comment)