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

Avoid reflection in CryptoConfigShims #272

Merged
merged 1 commit into from
Aug 10, 2020

Conversation

mgiles
Copy link

@mgiles mgiles commented Aug 10, 2020

Fixes #266

The previous code attempts to invoke an internal method in .NET Core as if it's non-generic, but in recent framework versions it is generic and the invocation fails. This commit replaces the call with a non-reflective call on a public method to avoid similar backwards-breaking changes in the future.

I've tested this code, and it successfully signs a VSTO ClickOnce archive.

Note: There are some special cases handled by the internal method System.Security.Cryptography.Xml.CryptoHelpers.CreateFromName that are not handled by the replacement method, CryptoConfig.CreateFromName (they're explicitly listed in a switch in CryptoHelpers.CreateFromKnownName. However, the only names used in CryptoConfigShims are for RSAPKCS1SignatureFormatter and RSAPKCS1SignatureDeformatter, neither of which appear to be in the list of special cases. So for the purposes of CryptoConfigShims, I think the new behaviour is equivalent.

dotnet#266

The previous code attempts to invoke an internal method in .NET Core as
if it's non-generic, but in recent framework versions it _is_ generic.
This commit replaces the call with a non-reflective call on a public
method to avoid similar backwards-breaking changes in the future.

Note: There are some special cases handled by the internal method
System.Security.Cryptography.Xml.CryptoHelpers.CreateFromName that
are not handled by the replacement method, CryptoConfig.CreateFromName.
However, the only names used in CryptoConfigShims are for
RSAPKCS1SignatureFormatter and RSAPKCS1SignatureDeformatter, neither of
which appear to be in the list of special cases. So for the purposes of
CryptoConfigShims, I think the new behaviour is equivalent.
@clairernovotny clairernovotny merged commit 5fdcd8f into dotnet:master Aug 10, 2020
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.

CryptoConfigShims incorrectly calls an internal .NET core method using reflection
2 participants