private string GetSha256Thumbprint() { if (_thumbprint is null) { var key = Jwk.FromRSAParameters(_privateKey.ExportParameters(false)); string json = "{\"e\":\"" + key.Exponent + "\",\"kty\":\"RSA\",\"n\":\"" + key.Modulus + "\"}"; using (var sha256 = SHA256.Create()) { byte[] hash = sha256.ComputeHash(Encoding.UTF8.GetBytes(json)); _thumbprint = Base64Url.Encode(hash); } } return(_thumbprint); }
private JsonObject GetMessageHeader(string url, Nonce nonce) { var header = new JsonObject { { "alg", AlgorithmNames.RS256 }, { "nonce", nonce.Value }, { "url", url } }; if (_accountUrl != null) { header.Add("kid", _accountUrl); } else { var jwk = Jwk.FromRSAParameters(_privateKey.ExportParameters(includePrivateParameters: false)); header.Add("jwk", JsonObject.FromObject(jwk)); } return(header); }