jwtDecodeAsym (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

All

Firmware version:

1.70.00


jwtDecodeAsym decodes a token into a JWT object.

jwtDecodeAsym is used for asymmetrical encryption and unencrypted tokens. For symmetrical encryption, see jwtDecodeSym.

 

When the JWT object is no longer needed, it must be released using jwtFree.

 

Note: To be sure that the signature was valid, it is important to check that it used the expected encryption algorithm with jwtAlgGet.

 

Input:

token : STRING

The token to decode.

 

cert : STRING

The name of the certificate to use for decoding the token. If not provided, no validation of the signature will be done.

 

 

Output:

jwt : SYSHANDLE

A handle to the decoded JWT object.

 

Returns: INT

1

- Success

0

- Function is not supported.

-1

- Invalid token.

-2

- Could not allocate JWT, there may be too many in use.

-4

- Could not find certificate.

-5

- Failed to parse certificate.

-99

- Failed to decode JWT.

 

 

Declaration:

FUNCTION jwtDecodeAsym : INT;
VAR_INPUT
  jwt   : ACCESS SYSHANDLE;
  token : STRING;
  cert  : STRING;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  rc  : INT;
  jwt : SYSHANDLE;
END_VAR;
 
BEGIN
  ...
  // Decode JWT
  rc := jwtDecodeAsym(jwt := jwt,
     token := "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.ySDdaDkS5f0NlFCS2gg-hwZ82kYbBjJ6kwL1iqVXPMF6cNprhQntupGJyXtmtETicNq82eV1zd8vtYwUhkJIUX-V8NavW65E0AWS_Qdof2jyyIZangjBL5q7cV-qDbRmnygaHwz4G5x4NyCWeoWfkvgzdBEoN98a62OwpmghrPhfKur7ZXhmXXyKro5V4fcTHxD5bLCDM3wd8BREfs8AQHt4jxwYgZwgwCp1739rSUSW-LRKNaOxQNKP062QvZYEEvwD0557Eo2Pj5gNGFqKMtYDaSfydIPhIVfZbsEeJ-6ITtPB5hmMuXOONFT2ARgxi8qW26FSsz6ZKba2HMDtBg",
    cert := "enc_pub");
  ...
END;
 
END_PROGRAM;