Esempio n. 1
0
        public void CanReadTestVectorPayments()
        {
            var tests = new[]
            {
                "data/payreq1_sha256_omitteddefault.paymentrequest",
                "data/payreq1_sha256.paymentrequest",
                "data/payreq2_sha256_omitteddefault.paymentrequest",
                "data/payreq2_sha256.paymentrequest",
                "data/payreq1_sha1_omitteddefault.paymentrequest",
                "data/payreq1_sha1.paymentrequest",
                "data/payreq2_sha1_omitteddefault.paymentrequest",
                "data/payreq2_sha1.paymentrequest",
            };

            foreach (var provider in new ICertificateServiceProvider[]
            {
                new WindowsCertificateServiceProvider(X509VerificationFlags.IgnoreNotTimeValid |
                                                      X509VerificationFlags.AllowUnknownCertificateAuthority |
                                                      X509VerificationFlags.IgnoreRootRevocationUnknown |
                                                      X509VerificationFlags.IgnoreCertificateAuthorityRevocationUnknown |
                                                      X509VerificationFlags.IgnoreEndRevocationUnknown)
            })
            {
                PaymentRequest.DefaultCertificateServiceProvider = provider;
                foreach (var test in tests)
                {
                    var bytes   = File.ReadAllBytes(test);
                    var request = PaymentRequest.Load(bytes);
                    AssertEx.Equal(request.ToBytes(), bytes);

                    Assert.True(request.VerifySignature());
                    request = PaymentRequest.Load(PaymentRequest.Load(bytes).ToBytes());
                    Assert.True(request.VerifySignature());
                    Assert.True(request.VerifyChain());
                }
            }
        }