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

Fix #95 #107

Merged

Conversation

hugmyndakassi
Copy link
Contributor

@hugmyndakassi hugmyndakassi commented Sep 30, 2024

  • Certificate got another ctor which takes the flags to pass when formatting the X509_NAME values
  • The default formatting changed to XN_FLAG_RFC2253 but can be overridden from the outside by defining UTHENTICODE_DEFAULT_XN_FLAGS
  • This introduces an incompatibility if the caller assumes that the issuer and subject can be compared in their string form

@hugmyndakassi
Copy link
Contributor Author

Please note that the return value of name_to_string is currently unused because the previous implementation also didn't perform error checking for the failure case and I wasn't sure what you'd desire inside a ctor.

private:
Certificate(X509 *cert);
explicit Certificate(X509 *cert);
Certificate(X509 *cert, unsigned long xn_flags);
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather not expose a custom ctor here -- it effectively binds us to the OpenSSL ABI (via xn_flags, plus formalizing that we support OpenSSL's weird stringification, which wasn't intentional), and exposes a decision point that I suspect 99% of people using this library don't need.

If the goal is to change the default to XN_FLAG_RFC2253 + UTF-8 conversion, let's just do that and then I'll perform a major release to indicate potential breakage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Amended the original commit. Please have a look if this resolves the issue for you, @woodruffw.

@hugmyndakassi hugmyndakassi force-pushed the using-x509_name_print_ex-for-DNs branch from cd8bb0a to 4c02ad3 Compare October 8, 2024 10:49
@hugmyndakassi
Copy link
Contributor Author

hugmyndakassi commented Oct 15, 2024

@woodruffw is there something you would like fixed in this PR prior to merging? I don't see any activity since my comment from last week (this could mean some message is stuck in draft state, invisible to me).

@woodruffw
Copy link
Member

woodruffw commented Oct 15, 2024 via email

Comment on lines 158 to 159
(void) name_to_string(issuer_, X509_get_issuer_name(cert), xn_flags);
(void) name_to_string(subject_, X509_get_subject_name(cert), xn_flags);
Copy link
Member

Choose a reason for hiding this comment

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

Just making sure I understand: you've put (void) here to tell the compiler to ignore the return type, right? If so assigning to std::ignore is probably a little more idiomatic, or just dropping the return type from name_to_string entirely.

@woodruffw
Copy link
Member

NB: Per test failures, you'll need to update a few test strings to match the new string format: https://github.com/trailofbits/uthenticode/actions/runs/11233887711/job/31228529055?pr=107

@hugmyndakassi hugmyndakassi force-pushed the using-x509_name_print_ex-for-DNs branch from 4c02ad3 to 7e24241 Compare October 28, 2024 10:46
- Certificate got another ctor which takes the flags to pass when
  formatting the X509_NAME values
- The default formatting changed to XN_FLAG_RFC2253 but can be overridden
  from the outside by defining UTHENTICODE_DEFAULT_XN_FLAGS
- This introduces an incompatibility _if_ the caller assumes that the
  issuer and subject can be compared in their string form
@hugmyndakassi hugmyndakassi force-pushed the using-x509_name_print_ex-for-DNs branch from 7e24241 to 8428b65 Compare October 28, 2024 10:49
@hugmyndakassi
Copy link
Contributor Author

hugmyndakassi commented Oct 28, 2024

NB: Per test failures, you'll need to update a few test strings to match the new string format: https://github.com/trailofbits/uthenticode/actions/runs/11233887711/job/31228529055?pr=107

Should be resolved now.

Not sure what about the mac errors, though. I have no mac to test.

@woodruffw
Copy link
Member

Not sure what about the mac errors, though. I have no mac to test.

Don't worry about those -- that's been an issue for a while, and I haven't had time to triage it. We can merge with the mac builds failing.

@woodruffw woodruffw changed the title This fixes issue #95 Fix #95 Oct 28, 2024
@woodruffw woodruffw merged commit 19005f0 into trailofbits:master Oct 28, 2024
7 of 10 checks passed
@woodruffw
Copy link
Member

Thanks @hugmyndakassi!

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.

2 participants