Repository navigation
OpenSSL 4.1 compatibility - #137288
OpenSSL 4.1 compatibility#137288
Conversation
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
🟡 Changes recommended
The new ignored-error path lacks regression coverage confirming that duplicate noncritical extensions are accepted on OpenSSL 4.1 while independent errors, such as expiration, are still reported.
1 open issue
What changed in this PR
This PR preserves existing .NET certificate-validation behavior when using OpenSSL 4.1.
Changes:
- Restores hostname common-name fallback when no DNS Subject Alternative Name exists, including IP-literal compatibility checks.
- Ignores OpenSSL’s duplicate-extension error while retaining other chain-validation errors.
- Adds OpenSSL 4.x error definitions and expands chain-error storage to 128 bits.
| File | Description |
|---|---|
src/native/libs/System.Security.Cryptography.Native/opensslshim.h |
Adds the OpenSSL 4.1 version constant. |
src/native/libs/System.Security.Cryptography.Native/openssl.c |
Centralizes hostname checks and restores conditional subject fallback. |
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslX509ChainProcessor.cs |
Suppresses duplicate-extension errors and expands error storage. |
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509.cs |
Adds OpenSSL 4.x verification codes and renames the 3.x code definitions. |
Review effort: Balanced
Parenthesize the complete cast expressions so direct member access applies to the typed pointers returned by the stack accessors. Co-authored-by: Copilot <[email protected]>
|
Tagging subscribers to this area: @bartonjs, @vcsjones, @dotnet/area-system-security |
|
/backport to release/11.0 |
|
Started backporting to |
|
/backport to release/10.0 |
|
Started backporting to |
|
@vcsjones backporting to git am output$ git cherry-pick 014646c4ceb68fe5b705f27db6a431c7227a718a
Auto-merging src/native/libs/System.Security.Cryptography.Native/openssl.c
CONFLICT (content): Merge conflict in src/native/libs/System.Security.Cryptography.Native/openssl.c
Auto-merging src/native/libs/System.Security.Cryptography.Native/opensslshim.h
error: could not apply 014646c4ceb... OpenSSL 4.1 compatibility
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: Restore subject name matching with OpenSSL 4.1
Using index info to reconstruct a base tree...
M src/native/libs/System.Security.Cryptography.Native/openssl.c
M src/native/libs/System.Security.Cryptography.Native/opensslshim.h
Falling back to patching base and 3-way merge...
Auto-merging src/native/libs/System.Security.Cryptography.Native/openssl.c
CONFLICT (content): Merge conflict in src/native/libs/System.Security.Cryptography.Native/openssl.c
Auto-merging src/native/libs/System.Security.Cryptography.Native/opensslshim.h
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Restore subject name matching with OpenSSL 4.1
Error: The process '/usr/bin/git' failed with exit code 128 |
|
@vcsjones backporting to git am output$ git cherry-pick 014646c4ceb68fe5b705f27db6a431c7227a718a
Auto-merging src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509.cs
Auto-merging src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslX509ChainProcessor.cs
CONFLICT (content): Merge conflict in src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslX509ChainProcessor.cs
Auto-merging src/native/libs/System.Security.Cryptography.Native/openssl.c
CONFLICT (content): Merge conflict in src/native/libs/System.Security.Cryptography.Native/openssl.c
Auto-merging src/native/libs/System.Security.Cryptography.Native/opensslshim.h
error: could not apply 014646c4ceb... OpenSSL 4.1 compatibility
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: Restore subject name matching with OpenSSL 4.1
Using index info to reconstruct a base tree...
M src/native/libs/System.Security.Cryptography.Native/openssl.c
M src/native/libs/System.Security.Cryptography.Native/opensslshim.h
Falling back to patching base and 3-way merge...
Auto-merging src/native/libs/System.Security.Cryptography.Native/openssl.c
CONFLICT (content): Merge conflict in src/native/libs/System.Security.Cryptography.Native/openssl.c
Auto-merging src/native/libs/System.Security.Cryptography.Native/opensslshim.h
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Restore subject name matching with OpenSSL 4.1
Error: The process '/usr/bin/git' failed with exit code 128 |

This makes a couple of fixes that addresses .NET compatibility with OpenSSL 4.1.
X509_check_hostnamenow requires opting in to using the subject of the certificate - only the Subject Alternative Name extension is considered. This is not quite as simple as "pass a flag" - it's explained in comments for posterity.X509_V_ERR_DUPLICATE_EXTENSIONfor certificates with duplicate extensions. .NET today does not error for this, and nor do we have a good way to map it. We also ignore it for macOS currently. We can error for duplicate extensions if we want to, but that would 1) be something that can't be back ported and 2) needs to change for macOS as well, so it should be done separately from this pull request, if at all.Fixes #137209