Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSL Improvements (2) #10866

Merged
merged 9 commits into from
Jan 7, 2025
Merged

SSL Improvements (2) #10866

merged 9 commits into from
Jan 7, 2025

Conversation

Ashod
Copy link
Contributor

@Ashod Ashod commented Jan 7, 2025

More non-functional error-handling improvements.
This greatly simplifies error handling, without introducing any functional changes.
Functional changes will follow.

  • wsd: net: simplify ssl error handling
  • wsd: net: unify SSL error logging
  • wsd: net: remove single-use macro
  • wsd: net: conditional use of SSL_ERROR_WANT_RETRY_VERIFY
  • wsd: include missing atomic header
  • wsd: net: assert catch-all SSL errors
  • wsd: net: peek the error only once
  • wsd: net: assert on unexpected SSL errors
  • wsd: net: hoist restoring errno

Ashod added 9 commits January 7, 2025 06:34
Change-Id: Iedd2713d405720b90e8bfb6d4b4edf4708dda751
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Change-Id: I2ab0e5e94071895d227f0469dd0f62a7d9310255
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Change-Id: I6235ec5a6e84ebcf6e9a4131fb0e94de961a61fe
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
SSL_ERROR_WANT_RETRY_VERIFY was added in version
3.0.1 of OpenSSL, so it's not available with 1.1.1.

Also, simplify the version number comparison.

Change-Id: Ie7315b2a3f96e2e81dabf9f4e032698f2ffbc9c3
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Change-Id: I4cd756422d6fb72e2132386ae0b0c1af6ca504af
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
The catch-all case still needs to know what
errors it could deal with, so we handle them
properly. For now, we only expect SYSCALL
and SSL errors only.

Change-Id: I5a21abe636dfede4174d8be8cc8001fcdbfcc12d
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Change-Id: Icf459bf409c4f8422ce95bbbe279951799f313b2
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Some error can happen only with certain features.
If these features are used, their error cases
must be handled. The assertions is to catch
if a feature is enabled without its corresponding
error handling.

Change-Id: Ifd1b926a95a692eccde44d2d60b2f353eb3d5ea1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
It's repetitive and error prone to
restore errno before each return
from the error handler.

Change-Id: I7990c1a2f5c6b1730586e4c6e1774d929685448b
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
@Ashod Ashod changed the title private/ash/ssl SSL Improvements (2) Jan 7, 2025
@Ashod Ashod requested review from mmeeks and caolanm January 7, 2025 13:20
Copy link
Contributor

@mmeeks mmeeks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - thanks Ash =) still think an "ErrnoPreserver" class would be best for this but - fine as-is.

@@ -363,6 +363,7 @@ class SslStreamSocket final : public StreamSocket
// Not an error; should be handled elsewhere.
case SSL_ERROR_NONE: // 0
LOG_TRC(SSL_LOG_PREFIX(context, sslError, rc, last_errno) << ": " << bioErrStr);
errno = last_errno; // Restore errno.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would love to do this with some RAII guard class

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, we could. What complicates it a little is that we override it in a couple of cases.

@mmeeks mmeeks merged commit 63cb2cb into master Jan 7, 2025
14 checks passed
@mmeeks mmeeks deleted the private/ash/ssl branch January 7, 2025 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants