TsgcHTTP_OAuth2_ClientMethods › PublicKeyToJWK

PublicKeyToJWK Method

Converts a PEM-encoded public key to its JWK (JSON Web Key) representation.

Syntax

function PublicKeyToJWK(const aPEM: String): String;

Parameters

NameTypeDescription
aPEMconst StringA PEM-encoded public key (EC P-256 or RSA) to be converted to JWK.

Return Value

The public key serialized as a JWK JSON string (for example {"kty":"EC","crv":"P-256","x":"...","y":"..."}), suitable for assignment to DPoPOptions.PublicKeyJWK or for registration with the authorization server.

Remarks

Use this helper when you already have an externally generated key pair and need to publish the public half in JWK form (for example to register a client assertion key or to populate DPoPOptions.PublicKeyJWK without calling GenerateDPoPKeyPair). The input must be a single PEM block containing -----BEGIN PUBLIC KEY-----/-----END PUBLIC KEY-----.

Example

var
  vJWK: String;
begin
  vJWK := oAuth2.PublicKeyToJWK(oAuth2.DPoPOptions.PrivateKey.Text);
  oAuth2.DPoPOptions.PublicKeyJWK := vJWK;
end;

Back to Methods