-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix build compilation with OpenSSL 4.0-dev. #122744
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
base: main
Are you sure you want to change the base?
Conversation
OpenSSL marked a few methods that could return const as requiring const. Add const qualifiers where needed.
| if (x509) | ||
| { | ||
| X509_PUBKEY* pubkey = X509_get_X509_PUBKEY(x509); | ||
| const X509_PUBKEY* pubkey = X509_get_X509_PUBKEY(x509); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only used by X509_PUBKEY_get0_param below, which already has the parameter qualified as const, so we can just mark our variable as const and it will still work for the call.
Okay, that is not true with OpenSSL 1.1.x. We are going to have to discard the qualifiers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates the System.Security.Cryptography.Native bindings to be compatible with OpenSSL 4.0-dev by adding const qualifiers to function signatures and local variables where OpenSSL now requires them.
Key Changes:
- Updated
CryptoNative_GetX509PublicKeyBytesreturn type to returnconst ASN1_BIT_STRING* - Added const qualifiers to local
X509_PUBKEY*variables in two functions
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/native/libs/System.Security.Cryptography.Native/openssl.h | Updated function signature for CryptoNative_GetX509PublicKeyBytes to return const pointer |
| src/native/libs/System.Security.Cryptography.Native/openssl.c | Added const qualifiers to function implementation and local variables to match OpenSSL 4.0-dev API requirements |
| the public key. | ||
| */ | ||
| ASN1_BIT_STRING* CryptoNative_GetX509PublicKeyBytes(X509* x509) | ||
| const ASN1_BIT_STRING* CryptoNative_GetX509PublicKeyBytes(X509* x509) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This interior pointer is later fed in to CryptoNative_GetAsn1StringBytes which does not modify the structure. So while the const is "erased" across the p/invoke boundary, the uses of the interior pointer do not violate the const requirement.
|
Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones |
OpenSSL marked a few methods that could return const as requiring const. Add const qualifiers where needed.
If we fix this now, we can keep scouting against openssl's main branch.
Fixes vcsjones/runtime-ci#9.