コード例 #1
0
        /// <summary>
        /// Returns the current signing key.
        /// </summary>
        /// <returns></returns>
        public async Task <RsaKeyContainer> GetCurrentKeyAsync()
        {
            _logger.LogDebug("Getting the current key.");

            var(_, key) = await GetAllKeysInternalAsync();

            if (_logger.IsEnabled(LogLevel.Information))
            {
                var age       = _clock.GetAge(key.Created);
                var expiresIn = _options.KeyExpiration.Subtract(age);
                var retiresIn = _options.KeyRetirement.Subtract(age);
                _logger.LogInformation("Active signing key found with kid {kid}. Expires in {KeyExpiration}. Retires in {KeyRetirement}", key.Id, expiresIn, retiresIn);
            }

            return(key);
        }
コード例 #2
0
        /// <inheritdoc />
        public async Task <IEnumerable <KeyContainer> > GetCurrentKeysAsync()
        {
            _logger.LogDebug("Getting the current key.");

            var(_, currentKeys) = await GetAllKeysInternalAsync();

            if (_logger.IsEnabled(LogLevel.Information))
            {
                foreach (var key in currentKeys)
                {
                    var age       = _clock.GetAge(key.Created);
                    var expiresIn = _options.RotationInterval.Subtract(age);
                    var retiresIn = _options.KeyRetirementAge.Subtract(age);
                    _logger.LogInformation("Active signing key found with kid {kid} for alg {alg}. Expires in {KeyExpiration}. Retires in {KeyRetirement}", key.Id, key.Algorithm, expiresIn, retiresIn);
                }
            }

            return(currentKeys);
        }