dotnet / sign

Code Signing CLI tool supporting Authenticode, NuGet, VSIX, and ClickOnce
MIT License
447 stars 84 forks source link

Test: 2 flaky OPC timestamping tests #671

Open dtivel opened 3 months ago

dtivel commented 3 months ago

Two tests failed then passed on rerun for https://github.com/dotnet/sign/commit/394fc50bebb3ddaa3f79fc975f552d4ea2787552:

details ``` System.Security.Cryptography.CryptographicException : ASN1 corrupted data.\r\n---- System.Formats.Asn1.AsnContentException : The provided data does not represent a valid tag. at System.Security.Cryptography.Pkcs.Rfc3161TimestampRequest.ProcessResponse(ReadOnlyMemory`1 source, Rfc3161TimestampToken& token, Rfc3161RequestResponseStatus& status, Int32& bytesConsumed, Boolean shouldThrow) at System.Security.Cryptography.Pkcs.Rfc3161TimestampRequest.ProcessResponse(ReadOnlyMemory`1 responseBytes, Int32& bytesConsumed) at Sign.Core.Timestamp.TimestampBuilder.SubmitTimestampRequest(Uri timestampUri, Oid digestOid, TimestampNonce nonce, TimeSpan timeout, Byte[] digest) in /_/src/Sign.Core/Tools/VsixSignTool/Timestamp/TimestampBuilder.netcoreapp.cs:line 34 at Sign.Core.OpcPackageTimestampBuilder.SignAsync(Uri timestampServer, HashAlgorithmName timestampAlgorithm) in /_/src/Sign.Core/Tools/VsixSignTool/OpcPackageTimestampBuilder.cs:line 51 at Sign.Core.Test.OpcPackageSigningTests.ShouldTimestampFileWithRsa(Int32 keySizeInBits, HashAlgorithmName hashAlgorithmName, HashAlgorithmName timestampDigestAlgorithm) in /_/test/Sign.Core.Test/Tools/VSIXSignTool/OpcPackageSigningTests.cs:line 83 --- End of stack trace from previous location --- ----- Inner Stack Trace ----- at System.Formats.Asn1.AsnDecoder.ReadEncodedValue(ReadOnlySpan`1 source, AsnEncodingRules ruleSet, Int32& contentOffset, Int32& contentLength, Int32& bytesConsumed) at System.Formats.Asn1.AsnValueReader.PeekEncodedValue() at System.Security.Cryptography.Pkcs.Rfc3161TimestampRequest.ProcessResponse(ReadOnlyMemory`1 source, Rfc3161TimestampToken& token, Rfc3161RequestResponseStatus& status, Int32& bytesConsumed, Boolean shouldThrow) ```
details ``` Assert.True() Failure\r\nExpected: True\r\nActual: False at Sign.Core.Test.Crypt32Tests.ShouldTimestampData() in /_/test/Sign.Core.Test/Tools/VSIXSignTool/Crypt32Tests.cs:line 34 at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor) at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr) ```

The next best step would probably be to add logging to the timestamp server to log every request/response. Or, if Visual Studio's "Run Until Failure" feature works well enough, locally debug a failure.

CC @javierdlg