Example #1
0
        /// <summary>
        /// Computes the DNS value for the <paramref name="challenge"/>.
        /// </summary>
        /// <param name="challenge">The challenge.</param>
        /// <param name="key">The key.</param>
        /// <returns>The value for the text DNS record.</returns>
        public static string ComputeDnsValue(this ChallengeEntity challenge, IAccountKey key)
        {
            var keyAuthString = challenge.ComputeKeyAuthorization(key);
            var keyAuthBytes  = Encoding.UTF8.GetBytes(keyAuthString);
            var sha256        = new Sha256Digest();
            var hashed        = new byte[sha256.GetDigestSize()];

            sha256.BlockUpdate(keyAuthBytes, 0, keyAuthBytes.Length);
            sha256.DoFinal(hashed, 0);

            var dnsValue = JwsConvert.ToBase64String(hashed);

            return(dnsValue);
        }
Example #2
0
        public async Task CanComputeDnsKeyAuth()
        {
            var challenge = new ChallengeEntity
            {
                Token = "6csJt_REONi1guIpCqdw6wCP5hL8YxtOhTCETu7ECYY",
                Type  = "dns-01"
            };

            var keyAuth = challenge.ComputeDnsValue(await Helper.LoadkeyV1());

            Assert.Equal(
                "_R4B3fDaVztZshDzof1sXQ90V-JlADF_2WFua87u7qU",
                keyAuth);
        }
Example #3
0
 /// <summary>
 /// Computes the key authorization string for <paramref name="challenge"/>.
 /// </summary>
 /// <param name="challenge">The challenge.</param>
 /// <param name="key">The key.</param>
 /// <returns>The key authorization string.</returns>
 public static string ComputeKeyAuthorization(this ChallengeEntity challenge, IAccountKey key)
 => $"{challenge.Token}.{key.Thumbprint()}";