CryptoPro / corefx

This repo contains the .NET Core foundational libraries, called CoreFX. It includes classes for collections, file systems, console, XML, async and many others. We welcome contributions.
https://github.com/dotnet/core
MIT License
27 stars 7 forks source link

DecryptContent(RecipientInfoCollection recipientInfos, X509Certificate2Collection? extraStore) should throw AggregateException #68

Closed RufusJWB closed 10 months ago

RufusJWB commented 10 months ago

When decrypting a CMS object, the method DecryptContent(RecipientInfoCollection recipientInfos, X509Certificate2Collection? extraStore) iterates through all recipients of this CMS object: https://github.com/CryptoPro/corefx/blob/c44c962a8bb08c651042391797e0a84b62df71e3/src/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/EnvelopedCms.cs#L226 If working down the recipients results in more than one exception, only the last exception is thrown but the other exceptions are overwritten.

Here https://github.com/CryptoPro/corefx/blob/c44c962a8bb08c651042391797e0a84b62df71e3/src/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/EnvelopedCms.cs#L231

and

https://github.com/CryptoPro/corefx/blob/c44c962a8bb08c651042391797e0a84b62df71e3/src/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/EnvelopedCms.cs#L241

I'd like to propose that this behavior should be changed to throw an AggregateException with all collected exceptions.