Exemple #1
0
        public void should_pass_rsa_cert_check_v1_when_sign_is_self_generated_and_load_key_from_file()
        {
            //gien
            Dictionary <string, string> parameters = new Dictionary <string, string>
            {
                { "测试Key1", "测试Value1" },
                { "测试Key2", "测试Value2" }
            };

            parameters.Add("sign", AlipaySignature.Sign(parameters, TestAccount.Mock.AppPrivateKeyFile, "UTF-8", "RSA2", true));
            parameters.Add("sign_type", "RSA2");

            //when
            bool result = AlipaySignature.VerifyV1(parameters, TestAccount.Mock.AppPublicKeyFile, "UTF-8", "RSA2", true);

            //then
            Assert.AreEqual(result, true);
        }
Exemple #2
0
        public void should_pass_rsa_cert_check_v2_when_sign_is_self_generated()
        {
            //gien
            Dictionary <string, string> parameters = new Dictionary <string, string>
            {
                { "测试Key1", "测试Value1" },
                { "测试Key2", "测试Value2" },
                { "sign_type", "RSA2" }
            };

            parameters.Add("sign", AlipaySignature.Sign(parameters, TestAccount.ProdCert.AppPrivateKey, "UTF-8", "RSA2", false));

            //when
            bool result = AlipaySignature.CertVerifyV2(parameters, TestAccount.ProdCert.CertParams.AppCertPath, "UTF-8", "RSA2");

            //then
            Assert.AreEqual(result, true);
        }