示例#1
0
        public AlipayClient(
            IOptions <AlipayOptions> optionsAccessor,
            ILogger <AlipayClient> logger)
        {
            Options = optionsAccessor.Value;
            Logger  = logger;

            Client = new HttpClientEx();

            if (string.IsNullOrEmpty(Options.AppId))
            {
                throw new ArgumentNullException(nameof(Options.AppId));
            }

            if (string.IsNullOrEmpty(Options.RsaPrivateKey))
            {
                throw new ArgumentNullException(nameof(Options.RsaPrivateKey));
            }

            if (string.IsNullOrEmpty(Options.RsaPublicKey))
            {
                throw new ArgumentNullException(nameof(Options.RsaPublicKey));
            }

            PrivateRSAParameters = RSAUtilities.GetRSAParametersFormPrivateKey(Options.RsaPrivateKey);
            PublicRSAParameters  = RSAUtilities.GetRSAParametersFormPublicKey(Options.RsaPublicKey);
        }
示例#2
0
        public AlipayClient(
            IOptions <AlipayOptions> optionsAccessor,
            ILogger <AlipayClient> logger)
        {
            Options     = optionsAccessor.Value;
            this.logger = logger;
            try
            {
                Client = new HttpClientEx();

                if (string.IsNullOrEmpty(Options.AppId))
                {
                    throw new ArgumentNullException(nameof(Options.AppId));
                }

                if (string.IsNullOrEmpty(Options.RsaPrivateKey))
                {
                    throw new ArgumentNullException(nameof(Options.RsaPrivateKey));
                }

                if (string.IsNullOrEmpty(Options.RsaPublicKey))
                {
                    throw new ArgumentNullException(nameof(Options.RsaPublicKey));
                }

                PrivateRSAParameters = RSAUtilities.GetRSAParametersFormPrivateKey(Options.RsaPrivateKey);
                PublicRSAParameters  = RSAUtilities.GetRSAParametersFormPublicKey(Options.RsaPublicKey);
            }
            catch (Exception ex)
            {
                logger?.LogError($"{DateTime.Now} 支付宝初始化日志报错", ex.Message);
            }
        }
示例#3
0
        public static bool RSACheckContent(string data, string sign, string publicKey, string signType)
        {
            var key = RSAUtilities.GetRSAParametersFormPublicKey(publicKey);

            switch (signType)
            {
            case "RSA2":
                return(SHA256WithRSA.Verify(data, sign, key));

            default:
                return(SHA1WithRSA.Verify(data, sign, key));
            }
        }
        public AlipayNotifyClient(
            IOptions <AlipayOptions> optionsAccessor,
            ILogger <AlipayNotifyClient> logger)
        {
            Options = optionsAccessor.Value;
            Logger  = logger;

            if (string.IsNullOrEmpty(Options.RsaPublicKey))
            {
                throw new ArgumentNullException(nameof(Options.RsaPublicKey));
            }

            PublicRSAParameters = RSAUtilities.GetRSAParametersFormPublicKey(Options.RsaPublicKey);
        }