In this example we are going to create a JWT token using RSA RS256 private key and validate it with public key. RSA is a asymmetric signing method which uses different keys for both creation and validation. Use this if both creator (server app) and user (client app) of tokens are allowed to validate it. The token creator would know both private and public keys whereas the user would only know the public key.

Keys

Run command below first to create both private and public RSA keys.

.PHONY: cert
cert:
	openssl genrsa -out cert/id_rsa 4096
	openssl rsa -in cert/id_rsa -pubout -out cert/id_rsa.pub

#go #golang

Creating and validating a JWT RSA token in Golang
11.20 GEEK