I have a JWT Class which generates JWT Token using Private key. Now, I need to expose an endpoint for exernal application to get the public key in the form of JWKS KeySet. Can anyone guide me how to achieve this scenario.
The JWKS is located based on a URL specified in OpenID Connect metadata. The discovery of OIDC metadata uses a special endpoint that Salesforce already provides out of the box and you won't be able to override it. Ship your public key to the other party via an out-of-band means or use Salesforce's out of the box support for issuing JWTs.