Why can't I detect digital signature time stamps for .NET 4.8 by WinCrypt

Reus Weijie Hu 1 Reputation point
2024-11-12T07:17:10.74+00:00

I cannot use WinCrypt to read the time stamps of digital signatures in.NET 4.8 files, I would like to ask is this Microsoft mechanism?

else if (unsignedAttribute.Oid.Value == WinCrypt.szOID_RSA_counterSign_USA)

                        {

                            foreach (var signedAttribute in signerInfo.UnsignedAttributes)

                            {

                                if (signedAttribute.Oid.Value == WinCrypt.szOID_RSA_signingTime_USA)

                                {

                                    Pkcs9AttributeObject obj = new Pkcs9AttributeObject(signedAttribute.Values[0]);

                                    SignedCms rfcTimestampMessage = new SignedCms();

                                    rfcTimestampMessage.Decode(obj.RawData);

                                    rfcTimestampMessage.CheckSignature(true);

                                    foreach(var timeStampSignerInfo in rfcTimestampMessage.SignerInfos)

                                    {

                                        foreach(var timeStampAttribute in timeStampSignerInfo.SignedAttributes)

                                        {

                                            if (timeStampAttribute.Oid.Value == WinCrypt.szOID_RSA_signingTime)

                                            {

                                                Pkcs9SigningTime signingTime1 = (Pkcs9SigningTime)timeStampAttribute.Values[0];

                                                strTimeStamp = signingTime1.SigningTime.ToLocalTime().ToString();

                                            }                                                    

                                        }

                                    }

                                }

                            }

                        }

timeStampAttribute. Oid. Value = = WinCrypt. SzOID_RSA_signingTime

this statement can never be true, because no signingTime timeStampAttribute this Value. However, a timestamp is already shown in the file.

timeStampSignerInfo.SignedAttributes contains the values 1.2.840.113549.1.9.3 and 1.2.840.113549.1.9.4 but does not have 1.2.840.113549.1.9.5

2024-11-11_17-09-05

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,111 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.