private static void CanCreatePaymentRequestCore(object cert)
        {
            var request = new PaymentRequest();

            request.Details.Memo = "hello";
            request.Sign(cert, PKIType.X509SHA256);

            Assert.NotNull(request.MerchantCertificate);
            Assert.False(new X509Certificate2(request.MerchantCertificate, "", X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable).HasPrivateKey);
            Assert.True(request.VerifySignature());
            Assert.False(request.VerifyChain());
            AssertEx.CollectionEquals(request.ToBytes(), PaymentRequest.Load(request.ToBytes()).ToBytes());
            Assert.True(PaymentRequest.Load(request.ToBytes()).VerifySignature());
        }
예제 #2
0
        public void CanCreatePaymentRequest()
        {
            var cert    = new X509Certificate2("Data/NicolasDorierMerchant.pfx", (string)null, X509KeyStorageFlags.Exportable);
            var request = new PaymentRequest();

            request.Details.Memo = "hello";
            request.Sign(cert, PKIType.X509SHA256);

            Assert.NotNull(request.MerchantCertificate);
            Assert.True(request.VerifySignature());
            Assert.False(request.VerifyChain(X509VerificationFlags.IgnoreNotTimeValid));
            Assert.True(PaymentRequest.Load(request.ToBytes()).VerifySignature());
        }
예제 #3
0
        public void CanCreatePaymentRequest()
        {
            foreach (var provider in new ICertificateServiceProvider[]
            {
#if WIN
                new WindowsCertificateServiceProvider(X509VerificationFlags.IgnoreNotTimeValid)
#endif
            })
            {
                PaymentRequest.DefaultCertificateServiceProvider = provider;
                var cert    = File.ReadAllBytes("Data/NicolasDorierMerchant.pfx");
                var request = new PaymentRequest();
                request.Details.Memo = "hello";
                request.Sign(cert, PKIType.X509SHA256);

                Assert.NotNull(request.MerchantCertificate);
                Assert.True(request.VerifySignature());
                Assert.False(request.VerifyChain());
                AssertEx.CollectionEquals(request.ToBytes(), PaymentRequest.Load(request.ToBytes()).ToBytes());
                Assert.True(PaymentRequest.Load(request.ToBytes()).VerifySignature());
            }
        }
예제 #4
0
		private static void CanCreatePaymentRequestCore(object cert)
		{
			var request = new PaymentRequest();
			request.Details.Memo = "hello";
			request.Sign(cert, PKIType.X509SHA256);

			Assert.NotNull(request.MerchantCertificate);
#if WIN
			Assert.False(new X509Certificate2(request.MerchantCertificate, "", X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable).HasPrivateKey);
#endif
			Assert.True(request.VerifySignature());
			Assert.False(request.VerifyChain());
			AssertEx.CollectionEquals(request.ToBytes(), PaymentRequest.Load(request.ToBytes()).ToBytes());
			Assert.True(PaymentRequest.Load(request.ToBytes()).VerifySignature());
		}