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); }
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); } }
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); }