예제 #1
0
        public void NewTsViaFedict()
        {
            var provider = new Rfc3161TimestampProvider();

            byte[] tsBytes = provider.GetTimestampFromDocumentHash(hash, "http://www.w3.org/2001/04/xmlenc#sha256");

            TimeStampToken tst = tsBytes.ToTimeStampToken();

            Assert.True(tst.IsMatch(new MemoryStream(msg)));

            //Validate
            Timestamp ts;
            IList <CertificateList>   crls = new List <CertificateList>();
            IList <BasicOcspResponse> ocps = new List <BasicOcspResponse>();

            ts = tst.Validate(crls, ocps);
            Assert.True(Math.Abs((DateTime.UtcNow - ts.Time).TotalSeconds) < 60);
            if (ts.CertificateChain.ChainElements.Count == 2)
            {
                Assert.Equal(new DateTime(2022, 2, 28, 10, 0, 0), ts.RenewalTime);
                Assert.Equal(0, ocps.Count);
                Assert.Equal(1, crls.Count);
            }
            else if (ts.CertificateChain.ChainElements.Count == 3)
            {
                Assert.Equal(new DateTime(2031, 01, 21, 0, 0, 0), ts.RenewalTime);
                Assert.Equal(2, ocps.Count);
                Assert.Equal(0, crls.Count);
            }
            else
            {
                Assert.True(false, "The chain should be 3 (win) or 2 (linux) long");
            }
            Assert.Equal(0, ts.TimestampStatus.Count(x => x.Status != X509ChainStatusFlags.NoError));
            Assert.Equal(0, ts.CertificateChain.ChainStatus.Count(x => x.Status != X509ChainStatusFlags.NoError));

            ts = tst.Validate(crls, ocps, DateTime.UtcNow); //check clock skewness
            Assert.True(Math.Abs((DateTime.UtcNow - ts.Time).TotalSeconds) < 60);
            //Assert.AreEqual(new DateTime(2022, 2, 28, 10, 0, 0), ts.RenewalTime);
            Assert.Equal(0, ts.TimestampStatus.Count(x => x.Status != X509ChainStatusFlags.NoError));
            Assert.Equal(0, ts.CertificateChain.ChainStatus.Count(x => x.Status != X509ChainStatusFlags.NoError));
        }
예제 #2
0
        public void NewTsViaFedict()
        {
            var provider = new Rfc3161TimestampProvider();

            byte[] tsBytes = provider.GetTimestampFromDocumentHash(hash, "http://www.w3.org/2001/04/xmlenc#sha256");

            TimeStampToken tst = tsBytes.ToTimeStampToken();

            Assert.IsTrue(tst.IsMatch(new MemoryStream(msg)));

            //Validate
            Timestamp ts;
            IList <CertificateList>   crls = new List <CertificateList>();
            IList <BasicOcspResponse> ocps = new List <BasicOcspResponse>();

            ts = tst.Validate(crls, ocps);
            Assert.IsTrue(Math.Abs((DateTime.UtcNow - ts.Time).TotalSeconds) < 60);
            Assert.AreEqual(new DateTime(2021, 12, 15, 8, 0, 0), ts.RenewalTime);
            Assert.AreEqual(0, ts.TimestampStatus.Count(x => x.Status != X509ChainStatusFlags.NoError));
            Assert.AreEqual(0, ts.CertificateChain.ChainStatus.Count(x => x.Status != X509ChainStatusFlags.NoError));
        }