Skip to content

Instance Method

add(rsa:digestAlgorithm:kid:parser:serializer:)

Adds an RSA key to the collection.
@discardableResult func add(rsa key: some RSAKey, digestAlgorithm: DigestAlgorithm, kid: JWKIdentifier? = nil, parser: some JWTParser = DefaultJWTParser(), serializer: some JWTSerializer = DefaultJWTSerializer()) -> Self

Parameters

key

The RSAKey to use for signing. This key should be kept secure and not exposed.

kid

An optional JWKIdentifier (Key ID). If provided, it will be used to identify this key in the JWT kid header field.

Discussion

This method configures and adds an RSA key to the collection. The key is used for signing JWTs

Example Usage:

let collection = await JWTKeyCollection()
   .addRSA(key: myRSAKey)