C#SDK提交,在window上验证

1.x
tanghc 6 years ago
parent e09539bf72
commit c36b72cf91
  1. 21
      sop-sdk/sdk-csharp/SDKCSharp/Client/OpenClient.cs
  2. 4
      sop-sdk/sdk-csharp/SDKCSharp/Utility/SignUtil.cs
  3. 3
      sop-sdk/sdk-csharp/SDKTest/Program.cs

@ -23,29 +23,36 @@ namespace SDKCSharp.Client
private static char DOT = '.';
private static char UNDERLINE = '_';
public static String DATA_SUFFIX = "_response";
public static string DATA_SUFFIX = "_response";
private Dictionary<string, string> header = new Dictionary<string, string>();
private String url;
private String appId;
private String privateKey;
private string url;
private string appId;
private string privateKey;
private bool isPriKeyFromFile;
private OpenConfig openConfig;
private OpenRequest openRequest;
public OpenClient(string url, string appId, string privateKey) : this(url, appId, privateKey, DEFAULT_CONFIG)
public OpenClient(string url, string appId, string privateKey) : this(url, appId, privateKey,false, DEFAULT_CONFIG)
{
}
public OpenClient(string url, string appId, string privateKey, OpenConfig openConfig)
public OpenClient(string url, string appId, string privateKey, bool priKeyFromFile) : this(url, appId, privateKey, priKeyFromFile, DEFAULT_CONFIG)
{
}
public OpenClient(string url, string appId, string privateKey,bool priKeyFromFile, OpenConfig openConfig)
{
this.url = url;
this.appId = appId;
this.privateKey = privateKey;
this.isPriKeyFromFile = priKeyFromFile;
this.openConfig = openConfig;
this.openRequest = new OpenRequest(openConfig);
}
@ -78,7 +85,7 @@ namespace SDKCSharp.Client
}
form[this.openConfig.AppKeyName] = this.appId;
string content = SopSignature.getSignContent(form);
string sign = SignUtil.CreateSign(form, privateKey, request.Charset, request.SignType);
string sign = SignUtil.CreateSign(form, privateKey, request.Charset, isPriKeyFromFile, request.SignType);
form[this.openConfig.SignName] = sign;
string resp = this.doExecute(url, requestForm, header);

@ -21,9 +21,9 @@ namespace SDKCSharp.Utility
/// <param name="charset">字符集.</param>
/// <param name="signType">签名类型.</param>
/// <returns>返回签名.</returns>
public static string CreateSign(IDictionary<string, string> parameters, string privateKeyPem, string charset, string signType)
public static string CreateSign(IDictionary<string, string> parameters, string privateKeyPem, string charset, bool isFromFile, string signType)
{
return AlipaySignature.RSASign(parameters, privateKeyPem, charset, false, signType);
return AlipaySignature.RSASign(parameters, privateKeyPem, charset, isFromFile, signType);
}
}

@ -16,9 +16,10 @@ namespace SDKTest
// 私钥, PKCS1 1024
static string privateKey = "MIIEowIBAAKCAQEA5+OvJxeSzf44NxQ/cl7Ii+BzPg2k6sRcvH4ffOtU5Dzq1/oEvg02nxIhmwOHBZmjbmuUu0aLsfglUTAwqfXftfAKZidshsgj9NNh0/kxk0avRZ1UoljWGz/FxVZA0ogbxxhohPZ9jWcD+eBQcIwF2DtHfAJqWWZrYFnCMeHD8mPzxo2kwXSvDzi0vf9I2tKiYvNG26a9FqeYtPOoi81sdS3+70HOMdxP8ejXtyfnKpKz7Dx506LCIRS5moWS3Q5eTLV3NGX/1CSJ8wpQA2DAQTjVhX5eVu7Yqz12t8W+sjWM/tHUR6cgwYYR10p7tSCeCPzkigjGxKm4cYXWtATQJQIDAQABAoIBAHFDsgrrJca+NKEan77ycwx3jnKx4WrWjOF4zVKL9AQjiSYDNgvKknJyPb3kpC/lEoHdxGERHSzJoxib7DkoIqRQYhPxj73pxj5QfYk3P7LLJNNg/LTrpXDb3nL8JV9wIflGf87qQvstZTDJEyFWE4jBs7Hr0BxovWvri8InnzkmERJ1cbGJgNHe1Y3Zo2tw0yaHxQCxLuajP+notRZhD9bEp7uKeI0w9AvlW6k8m/7y10F0BK/TlyW8rQiEC391yOiRYoMcUh4hd2Q9bMx3jngZgX8PXIvZZcup4/pvWlv1alwhB2tsnLdazP62r1MO80vLyLunzGO+7WwCjEYlVaECgYEA+lQRFmbhKaPuAuXMtY31Fbga8nedka5TjnEV7+/kX+yowE2OlNujF+ZG8UTddTxAGv56yVNi/mjRlgD74j8z0eOsgvOq9mwbCrgLhLo51H9O/wAxtb+hBKtC5l50pBr4gER6d8W6EQNTSGojnMIaLXTkAZ5Qf6Z8e2HFVdOn0X0CgYEA7SSrTokwzukt5KldNu5ukyyd+C3D1i6orbg6qD73EP9CfNMfGSBn7dDv9wMSJH01+Ty+RgTROgtjGRDbMJWnfbdt/61NePr9ar5sb6Nbsf7/I0w7cZF5dsaFYgzaOfQYquzXPbLQHkpMT64bqpv/Mwy4F2lFvaYWY5fA4pC2uckCgYEAg75Ym9ybJaoTqky8ttQ2Jy8UZ4VSVQhVC0My02sCWwWXLlXi8y7An+Rec73Ve0yxREOn5WrQT6pkmzh7V/ABWrYi5WxODpCIjtSbo0fLBa3Wqle00b0/hdCITetqIa/cFs1zUrOqICgK3bKWeXqiAkhhcwSZwwSgwOKM04Wn7ZUCgYBvhHX2mbdVJfyJ8kc+hMOE/E9RHRxiBVEXWHJlGi8PVCqNDq8qHr4g7Mdbzprig+s0yKblwHAvrpkseWvKHiZEjVTyDipHgShY4TGXEigVvUd37uppTrLi8xpYcJjS9gH/px7VCdiq1d+q/MJP6coJ1KphgATm2UrgDMYNBWaYWQKBgEHRxrmER7btUF60/YgcqPHFc8RpYQB2ZZE0kyKGDqk2Data1XYUY6vsPAU28yRLAaWr/D2H17iyLkxP80VLm6QhifxCadv90Q/Wl1DFfOJQMW6avyQ0so6G0wFq/LJxaFK4iLXQn1RJnmTp6BYiJMmK2BhFbRzw8ssMoF6ad2rr";
static string filePath = "/Users/thc/logs/priKey.txt";
// 声明一个就行
static OpenClient client = new OpenClient(url, appId, privateKey);
static OpenClient client = new OpenClient(url, appId, filePath, true);
public static void Main(string[] args)
{

Loading…
Cancel
Save