getKey

suspend fun getKey(atTime: Instant = Clock.System.now()): CertifiedKey

Gets a certified key.

This may involve replenishing the key pool if the number of fresh keys falls below the 50% threshold.

When the key has been used, call markKeyAsUsed to ensure it won't be used again.

It is allowable to call this function to just prime the pool (i.e. the result isn't immediately used) so network I/O is reduced for future calls.

Return

the CertifiedKey containing the KeyInfo and its X509CertChain.

Parameters

atTime

the current time, to take into consideration for evicting expired keys.

Throws

if no valid keys are available.

CancellationException

if the coroutine is cancelled.