loadPrivateKeyJwk method

EvpPkey loadPrivateKeyJwk(
  1. Map<String, Object?> jwk
)
inherited

Loads an RSA private key from a JSON Web Key (RFC 7517).

This is the shape an OpenID Connect identity provider keeps its signing key in, and going through it directly avoids converting the key to PEM by hand just to sign a token. The CRT parameters (dp, dq, qi) are derived when the JWK omits them.

final jwk = jsonDecode(File('idp-private.jwk').readAsStringSync());
final key = openSsl.loadPrivateKeyJwk(jwk as Map<String, Object?>);
final signature = openSsl.sign(key, signingInput); // RS256

Throws FormatException when jwk is not an RSA key or is missing a required parameter.

Implementation

EvpPkey loadPrivateKeyJwk(Map<String, Object?> jwk) =>
    loadPrivateKeyDer(rsaPrivateKeyDerFromJwk(jwk));