dotnet/Documentation/compatibility/SignedXml.GetPublicKey-retu...

39 lines
1.5 KiB
Markdown
Raw Normal View History

## SignedXml.GetPublicKey returns RSACng on net462 (or lightup) without retargeting change
### Scope
Edge
### Version Introduced
4.6.2
### Version Reverted
4.7.1
### Source Analyzer Status
NotPlanned
### Change Description
2017-10-26 04:17:26 +08:00
Starting with the .NET Framework 4.6.2, the concrete type of the object returned by the <xref:System.Security.Cryptography.Xml.SignedXml.GetPublicKey%2A?displayProperty=nameWithType> method changed (without a quirk) from a CryptoServiceProvider implementation to a Cng implementation. This is because the implementation changed from using `certificate.PublicKey.Key` to using the internal `certificate.GetAnyPublicKey` which forwards to <xref:System.Security.Cryptography.X509Certificates.RSACertificateExtensions.GetRSAPublicKey%2A?displayProperty=nameWithType>.
- [x] Quirked
- [ ] Build-time break
### Recommended Action
Starting with apps running on the .NET Framework 4.7.1, you can use the CryptoServiceProvider implementation used by default in the .NET Framework 4.6.1 and earlier versions by adding the following configuration switch to the [runtime](~/docs/framework/configure-apps/file-schema/runtime/runtime-element.md) section of your app config file:
```xml
2017-10-10 04:22:58 +08:00
<AppContextSwitchOverrides value="Switch.System.Security.Cryptography.Xml.SignedXmlUseLegacyCertificatePrivateKey=true" />
```
### Affected APIs
2017-10-10 04:22:58 +08:00
* `M:System.Security.Cryptography.Xml.SignedXml.CheckSignatureReturningKey(System.Security.Cryptography.AsymmetricAlgorithm@)`
### Category
Security
<!--
2017-10-10 04:22:58 +08:00
Bug # 432261
-->