| .\" Automatically generated by Pandoc 3.10 | |
| .\" | |
| .TH "JWT\-VERIFY" "1" "" "jwt\-verify User Manual" "LibJWT C Library" | |
| .SH NAME | |
| \f[B]jwt\-verify\f[R] \- Verify a JSON Web Token | |
| .SH SYNOPSIS | |
| .PP | |
| \f[B]jwt\-verify\f[R] \f[B][options]\f[R] \f[I]token\f[R] \&... | |
| .PD 0 | |
| .P | |
| .PD | |
| \f[B]jwt\-verify\f[R] \f[B][options]\f[R] \- < \f[I]token\f[R] | |
| .SH DESCRIPTION | |
| \f[B]jwt\-verify\f[R] Decodes and (optionally) verifies the signature of | |
| a JSON Web Token. | |
| .PP | |
| By default, the token(s) will be decoded and verified. | |
| If there is a signature block on the JWT, then you must give a JWK key | |
| with the \f[B]\-k\f[R] option, or a JWK Set with the \f[B]\-r\f[R] | |
| option. | |
| Verifying a signature with \f[B]\-k\f[R] requires specifying the | |
| algorithm, so it must either be in the key file (as the \f[B]alg\f[R] | |
| attribute), or passed on the command line with the \f[B]\-a\f[R] | |
| argument. | |
| .PP | |
| \f[B]jwt\-verify\f[R] will not assume the algorithm from the JWT itself | |
| (for security reasons), however, the algorithm in the JWT must match | |
| what you provide to \f[B]jwt\-verify\f[R]. | |
| .PP | |
| Tokens may be passed on the command line, after any options, separated | |
| by spaces, or passed via \f[B]stdin\f[R], one per line. | |
| To use \f[B]stdin\f[R], you must pass \f[B]\-\f[R] as the last and only | |
| argument after any options. | |
| .PP | |
| Each line of \f[B]stdin\f[R] is one token, and the last line does not | |
| need a newline. | |
| An empty line is a token that fails. | |
| A line of 1048576 bytes (1 MiB) or more, not counting its newline, or | |
| one that has a NUL byte in it, is not verified, not even in part, and | |
| counts as one token that failed. | |
| .PP | |
| When using the \f[B]\-\-verbose\f[R] option, \f[B]jwt\-verify\f[R] will | |
| print the JSON \f[I]HEADER\f[R] and \f[I]PAYLOAD\f[R] to | |
| \f[B]stdout\f[R]. | |
| .PP | |
| If used in conjunction with \f[B]\-\-print\f[R], the JSON will be piped | |
| to the command\(cqs \f[B]stdin\f[R]. | |
| It will be called twice: once for \f[I]HEAD\f[R] and once for | |
| \f[I]PAYLOAD\f[R]. | |
| .PP | |
| One use is to pass it through \f[B]jq \-C\f[R] for indenting and | |
| colorization. | |
| Another would be to use an external program to validate the | |
| \f[I]PAYLOAD\f[R] contents. | |
| A non\-0 exit status from the program will cause verification to fail, | |
| and so will the program being ended by a signal. | |
| .PP | |
| The command need not read all of its input: if it stops reading, | |
| \f[B]jwt\-verify\f[R] is not ended (no matter how large the JSON is), | |
| and the program\(cqs exit status, or a signal that ends it, still | |
| decides whether the token passes. | |
| .SS Options | |
| .TP | |
| \f[B]\-h\f[R], \f[B]\-\-help\f[R] | |
| Show common options and quit. | |
| .TP | |
| \f[B]\-l\f[R], \f[B]\-\-list\f[R] | |
| List all supported algorithms that can be passed to the \f[B]\-a\f[R] | |
| option and quit. | |
| .TP | |
| \f[B]\-v\f[R], \f[B]\-\-verbose\f[R] | |
| Show the contents of the \f[I]HEADER\f[R] and \f[I]PAYLOAD\f[R] of the | |
| JWT in addition to verifying the token. | |
| .TP | |
| \f[B]\-q\f[R], \f[B]\-\-quiet\f[R] | |
| Do not output anything except for hard errors. | |
| The result is the exit status: see \f[B]EXIT STATUS\f[R]. | |
| .TP | |
| \f[B]\-a\f[R] \f[I]ALG\f[R], \f[B]\-\-algorithm\f[R]=\f[I]ALG\f[R] | |
| Specify the algorithm to be used when verifying the signature block of | |
| any tokens passed to the program. | |
| See \f[B]\-l\f[R] for values of \f[I]ALG\f[R]. | |
| Not accepted with \f[B]\-\-keyring\f[R], where a key\(cqs own | |
| \f[B]alg\f[R], if it has one, pins the algorithm. | |
| .TP | |
| \f[B]\-k\f[R] \f[I]FILE\f[R], \f[B]\-\-key\f[R]=\f[I]FILE\f[R] | |
| Path to a file containing a key in JSON Web Key format. | |
| If your keys are in PEM or DER (or some other common format that | |
| \f[I]OpenSSL\f[R] understands), then you can convert it to a JWK with | |
| the \f[B]key2jwk(1)\f[R] tool. | |
| .TP | |
| \f[B]\-r\f[R] \f[I]FILE\f[R], \f[B]\-\-keyring\f[R]=\f[I]FILE\f[R] | |
| Path to a file containing a JWK Set (JWKS) of candidate keys, used to | |
| verify Compact tokens and the (multi\-signature) JWS JSON Serialization | |
| (RFC 7515 ยง7.2). | |
| A signature naming a \f[B]kid\f[R] is matched to that key; a keyless | |
| signature is tried against every compatible key. | |
| A key whose \f[B]use\f[R] is not \f[B]sig\f[R], or whose | |
| \f[B]key_ops\f[R] names neither \f[B]verify\f[R] nor \f[B]sign\f[R], is | |
| not a candidate. | |
| Mutually exclusive with \f[B]\-\-key\f[R]. | |
| .TP | |
| \f[B]\-P\f[R] \f[I]POLICY\f[R], \f[B]\-\-policy\f[R]=\f[I]POLICY\f[R] | |
| Multi\-signature acceptance policy when a keyring is used: \f[B]any\f[R] | |
| (the default \(em accept if at least one signature verifies) or | |
| \f[B]all\f[R] (every signature in the token must verify). | |
| .TP | |
| \f[B]\-p\f[R] \f[I]CMD\f[R], \f[B]\-\-print\f[R]=\f[I]CMD\f[R] | |
| Pipe JSON of header and payload to \f[I]CMD\f[R] through its | |
| \f[B]stdin\f[R]. | |
| Requires \f[B]\-\-verbose\f[R]; without it the command would never run, | |
| so it is a usage error. | |
| .SH EXIT STATUS | |
| .TP | |
| \f[B]0\f[R] | |
| Every token was verified (its signature checked with \f[B]\-k\f[R] or | |
| \f[B]\-r\f[R]; with neither, an unsigned token is only decoded). | |
| .TP | |
| \f[B]1\f[R] | |
| A token failed, there was no token to verify (nothing to read on | |
| \f[B]stdin\f[R]), or the program could not do its work: a bad option, a | |
| key or keyring that could not be loaded, a read error. | |
| .PP | |
| The exit status is not the number of tokens that failed. | |
| It is 1 for one failure and for any number of them. | |
| .PP | |
| \f[B]\-\-help\f[R] and \f[B]\-\-list\f[R] verify nothing; given alone | |
| they exit 0, but given with anything else (a token, a key, another | |
| option) they are a usage error (exit 1). | |
| An argument that starts with \f[B]\-\f[R] is read as an option unless it | |
| comes after \f[B]\-\-\f[R], and a \f[B]\-\f[R] on its own selects | |
| \f[B]stdin\f[R] even after \f[B]\-\-\f[R]. | |
| To check a string that comes from somewhere you do not trust, write it | |
| to \f[B]stdin\f[R] as a single line, or reject it first if it starts | |
| with \f[B]\-\f[R], which a token never does. | |
| .SH BUGS | |
| See GitHub Issues: \c | |
| .UR https://github.com/benmcollins/libjwt/issues | |
| .UE \c | |
| .SH AUTHOR | |
| \f[B]jwt\-verify\f[R] was originally written by Jeremy Thien. | |
| Major rewriting and man page by Ben Collins \c | |
| .MT bcollins@libjwt.io | |
| .ME \c | |
| \&. | |
| .SH SEE ALSO | |
| \f[B]jwt\-generate(1)\f[R], \f[B]key2jwk(1)\f[R], \f[B]jwk2key(1)\f[R] |