I need to sign a JSON string with JOSE JWS (RSA) algorithm.
This will be a DLL, so to interchange data (with Delphi7) the only safe way is to call the functions with WideString variables.
This way:
const
c_json : WideString =
'{'#13#10+
'"someData": {'#13#10+
...
'"name": "Tétel 1",'#13#10+
'}';
...
function TMyClaims.GetAsString: TJSONStringType;
var w : WideString;
begin
w := c_json ; // normally it's WideString variable, this is only for testing
Result := UTF8Encode(w);
//ShowMessage( Result );
end;
Result gives back strange chars: "Tétel.." becomes "Tétel.."
I need this, because GetAsString is called by :
function TJWTSigner.GetSignInputString(aJWT: TJWT): UTF8String;
begin
Result:=aJWT.JOSE.AsEncodedString+'.'+aJWT.Claims.AsEncodedString
end;
in the fpjwt.pp unit Line: 379.
Here is a full example I've changed to fit for "pure JSON", not as TClaim payload:
https://gitlab.com/freepascal.org/fpc/source/-/blob/main/packages/fcl-web/examples/jwt/signrs256.lpr