X509Certificate2 cert = new X509Certificate2(@"D:\web\junjunmei\rest\apiclient_cert.p12", PayConfig.MchId, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
var privateKey = cert.PrivateKey.ToXmlString(true);
var certSerialNo = cert.SerialNumber;
using (RSACryptoServiceProvider sha256 = new RSACryptoServiceProvider())
{
byte[] dataInBytes = Encoding.UTF8.GetBytes(message);
sha256.FromXmlString(privateKey);
byte[] inArray = sha256.SignData(dataInBytes, CryptoConfig.MapNameToOID("SHA256"));
string sign = Convert.ToBase64String(inArray);
return sign;
}
https://pay.weixin.qq.com/docs/merchant/apis/platform-certificate/api-v3-get-certificates/get.html