Search code examples
jsonjwtjose4jjwk

How to set proxy server for Json Web Keys


I'm trying to build JWKS object for google JSON web keys to verify the signature of JWT token received from google. Inside our corporate environment, we need to set the proxy server to reach out external one. Below code runs outside the corporate environment.

HttpsJwks https_jwks = new HttpsJwks(GOOGLE_SIGN_KEYS); List<JsonWebKey> jwks_list = https_jwks.getJsonWebKeys();

Library: jose4j0.4.1

Thanks in advance.


Solution

  • HttpsJwks uses the SimpleGet interface to make the HTTP call. By default it's an instance of Get, which uses java's HttpsURLConnection. So I think using the https proxy properties should work - see https://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html for more about https.proxyHost and https.proxyPort.

    If you need to do something more exotic for whatever reason, you can set your own implementation/instance of SimpleGet on the HttpsJwks instance too.