AlexMAS / GostCryptography

.NET driver for ViPNet CSP and CryptoPro CSP
MIT License
128 stars 41 forks source link

ComputeSignature Exception #46

Closed VladislavChastnokov closed 1 year ago

VladislavChastnokov commented 1 year ago

I'm getting an exception while trying to sign some data "Индекс за пределами диапазона. Индекс должен быть положительным числом, а его размер не должен превышать размер коллекции. Имя параметра: index" в System.Security.Cryptography.X509Certificates.X509ChainElementCollection.get_Item(Int32 index) в System.Security.Cryptography.Pkcs.PkcsUtils.CreateBagOfCertificates(CmsSigner signer) в System.Security.Cryptography.Pkcs.SignedCms.Sign(CmsSigner signer, Boolean silent) в System.Security.Cryptography.Pkcs.SignedCms.ComputeSignature(CmsSigner signer, Boolean silent) в GostCryptography.Pkcs.GostSignedCms.ComputeSignature(CmsSigner signer, Boolean silent) в GostCryptography.Pkcs.GostSignedCms.ComputeSignature(CmsSigner signer)

Same code works on test machine, but fails on production, same certificate

VladislavChastnokov commented 1 year ago

The only difference is CryptoPro CSP version, exception happens on machine with CSP 5.0

AlexMAS commented 1 year ago

Hello! Thank you for the feedback. Which .NET version do you use?

VladislavChastnokov commented 1 year ago

4.5.2 and above

AlexMAS commented 1 year ago

I can suggest the next options:

VladislavChastnokov commented 1 year ago

Certificate that is used is the only one in the user storage, code checked line by line, there aren't anything missing that would prevent it from working at a glance, exception is somewhere deep in the library, i don't even understand what it means and where to begin to look to fix it

VladislavChastnokov commented 1 year ago

Issue is rather critical, as this is used in signing and sending important data, i need to get it working by april

AlexMAS commented 1 year ago

Could you create a test that reproduces the issue? Also specify .NET and CSP versions, the certificate properties. As I understand CryptoPro CSP 4.* works well?

VladislavChastnokov commented 1 year ago

Issue resolved by reinstalling CryptoPro, possibly got broken by VipNet Client update (both on the same machine)