我的任务是通过从标准 .p12 文件中检索详细信息来签署 Http 请求。我已经通过执行以下操作来检索 .p12 文件的哈希密码:
MD5 md5 = MD5.Create();
string pw = "test";
byte[] bytes = Encoding.Latin1.GetBytes(pw);
//Get the MD5 Hash for the bytes and convert to a Base64 string
byte[] hashBytes = md5.ComputeHash(bytes);
var computed = Convert.ToBase64String(hashBytes);
var cert = new System.Security.Cryptography.X509Certificates.X509Certificate2(@"C:\temp\test.p12", computed);
现在我有了证书对象,我需要构建一个 HTTP 签名来签署 http 请求。给出的一个示例是 http 签名应如下所示:
Signature: keyId="xxxxxxxxxx",
algorithm="rsa-sha512",
headers="(request-target) host date digest",
signature="twgegehrjrffndndndmd"
我的问题是如何根据我现在拥有的证书中给出的样本构建签名,以及如何将其包含在对资源的请求中?我知道这些细节需要通过标头与请求一起传递,我只需要查看一个如何将其组合在一起的示例。
Keyid = ?? algorithm = "rsa-sha512", headers = "(request-target) host date digest" signature = ????