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

New X509D2iError to improve error checking for X509_ext_get_d2i() #2240

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

HolyShitMan
Copy link

@HolyShitMan HolyShitMan commented May 17, 2024

First try to fix #2226:
New X509D2iError which represents the errors that can occur after calling X509_ext_get_d2i()

pub enum X509D2iError {
    InternalOpenSSLError(ErrorStack),
    ExtensionNotFoundError,
    ExtensionAmbiguousError,
}

All corresponding X509_ext_get_d2i() calls are adapted accordingly to not return Option<...>, but a Result. ExtensionNotFoundError is handled as None before.

If you got other ideas or expectations let me know.

@HolyShitMan HolyShitMan changed the title New x509d2i error to improve error checking for X509_ext_get_d2i() New x509D2iError to improve error checking for X509_ext_get_d2i() May 21, 2024
@HolyShitMan HolyShitMan changed the title New x509D2iError to improve error checking for X509_ext_get_d2i() New ``509D2iError to improve error checking for X509_ext_get_d2i() May 21, 2024
@HolyShitMan HolyShitMan changed the title New ``509D2iError to improve error checking for X509_ext_get_d2i() New X509D2iError to improve error checking for X509_ext_get_d2i() May 21, 2024
@HolyShitMan
Copy link
Author

Hi @botovq,
I have a couple of questions regarding this PR:

Thank you!

Copy link
Contributor

@botovq botovq left a comment

Choose a reason for hiding this comment

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

The approach looks sensible to me. I do not know when and how this crate is willing to do breaking changes to its public API. Maybe the less brutal way to do it would be to deprecate the existing API and point at new variants that return Result<_, X509D2iError>. It might even be possible to make the existing API wrappers of the new API that map the X509D2iError to None (this has upsides and downsides).

That's @sfackler and @alex's call, though.

openssl/src/error.rs Outdated Show resolved Hide resolved
openssl/src/error.rs Outdated Show resolved Hide resolved
openssl/src/error.rs Outdated Show resolved Hide resolved
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.

Improve error checking for X509_ext_get_d2i()
2 participants