I am looking to use Spring Boot to create an OAuth2 Authentication server that could be used by multiple Resource server. Consequently, I am needing to create the two server
First you must verify if the JWT is using asymmetric key or symmetric key. As @Child said, setVerifierKey will be used when an asymmetric key is used for encryption.
Second, make sure PublicKey has been encoded to string in the correct way:
import java.security.PublicKey;
import java.util.Base64;
PublicKey publicKey = getPublicKey();
String strPublicKey = Base64.getEncoder().encodeToString(publicKey.getEncoded());`
Third, make sure that the string-key passed to the setVerifierKey is formatted as below (you can test it here):
String verifierKey = String.format("-----BEGIN PUBLIC KEY-----\n%s\n-----END PUBLIC KEY-----", strPublicKey);
converter.setVerifierKey(verifierKey);
If in doubt, I recommend this article.