本文整理汇总了C#中ISigner.ExportJwk方法的典型用法代码示例。如果您正苦于以下问题:C# ISigner.ExportJwk方法的具体用法?C# ISigner.ExportJwk怎么用?C# ISigner.ExportJwk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISigner
的用法示例。
在下文中一共展示了ISigner.ExportJwk方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateDnsChallengeAnswer
/// <summary>
/// Returns a key-value pair that represents the DNS domain name that needs
/// to be configured (the key) and the value that should be returned (the value)
/// for a query against that domain name for a record of type TXT.
/// </summary>
/// <param name="dnsId"></param>
/// <param name="signer"></param>
/// <returns></returns>
public KeyValuePair<string, string> GenerateDnsChallengeAnswer(string dnsId, ISigner signer)
{
var resp = new
{
type = "dns",
token = Token
};
var json = JsonConvert.SerializeObject(resp);
var hdrs = new { alg = signer.JwsAlg, jwk = signer.ExportJwk() };
var signed = JwsHelper.SignFlatJsonAsObject(
signer.Sign, json, unprotectedHeaders: hdrs);
/*
// We format it as a set of lines broken on 100-character boundaries to make it
// easier to copy and put into a DNS TXT RR which normally have a 255-char limit
// so this result may need to be broken up into multiple smaller TXT RR entries
var sigFormatted = Regex.Replace(signed.signature,
"(.{100,100})", "$1\r\n");
*/
return new KeyValuePair<string, string>(
$"{DNS_CHALLENGE_NAMEPREFIX}{dnsId}",
signed.signature); /*sigFormatted);*/
}
示例2: GenerateHttpChallengeAnswer
/// <summary>
/// Returns a key-value pair that represents the Simple HTTP resource path that
/// needs to be configured (the key) and the resource content that should be returned
/// for an HTTP request for this path on a server that the target DNS resolve to.
/// </summary>
/// <param name="dnsId"></param>
/// <param name="signer"></param>
/// <param name="tls"></param>
/// <returns></returns>
public KeyValuePair<string, string> GenerateHttpChallengeAnswer(string dnsId, ISigner signer, bool tls)
{
var resp = new
{
type = "simpleHttp",
token = Token,
tls = tls
};
var json = JsonConvert.SerializeObject(resp);
var hdrs = new { alg = signer.JwsAlg, jwk = signer.ExportJwk() };
var signed = JwsHelper.SignFlatJsonAsObject(
signer.Sign, json, unprotectedHeaders: hdrs);
return new KeyValuePair<string, string>(
$"{HTTP_CHALLENGE_PATHPREFIX}{Token}",
JsonConvert.SerializeObject(signed, Formatting.Indented));
}
示例3: ComputeThumbprint
/// <summary>
/// Computes a thumbprint of the JWK using the argument Hash Algorithm
/// as per <see cref="https://tools.ietf.org/html/rfc7638">RFC 7638</see>,
/// JSON Web Key (JWK) Thumbprint.
/// </summary>
/// <param name="algor"></param>
/// <returns></returns>
public static byte[] ComputeThumbprint(ISigner signer, HashAlgorithm algor)
{
// As per RFC 7638 Section 3, we export the JWK in a canonical form
// and then produce a JSON object with no whitespace or line breaks
var jwkCanon = signer.ExportJwk(true);
var jwkJson = JsonConvert.SerializeObject(jwkCanon, Formatting.None);
var jwkBytes = Encoding.UTF8.GetBytes(jwkJson);
var jwkHash = algor.ComputeHash(jwkBytes);
return jwkHash;
}