diff --git a/openid-connect-client/src/main/java/org/mitre/openid/connect/client/AbstractOIDCAuthenticationFilter.java b/openid-connect-client/src/main/java/org/mitre/openid/connect/client/AbstractOIDCAuthenticationFilter.java index 076a75864..cb4d75ce7 100644 --- a/openid-connect-client/src/main/java/org/mitre/openid/connect/client/AbstractOIDCAuthenticationFilter.java +++ b/openid-connect-client/src/main/java/org/mitre/openid/connect/client/AbstractOIDCAuthenticationFilter.java @@ -608,10 +608,10 @@ public class AbstractOIDCAuthenticationFilter extends if (serverConfig.getJwkSigningUrl() != null) { // prefer the JWK - signingKey = keyFetch.retrieveJwkKey(serverConfig); + signingKey = keyFetch.retrieveJwkKey(serverConfig.getJwkSigningUrl()); } else if (serverConfig.getX509SigningUrl() != null) { // use the x509 only if JWK isn't configured - signingKey = keyFetch.retrieveX509Key(serverConfig); + signingKey = keyFetch.retrieveX509Key(serverConfig.getX509SigningUrl()); } else { // no keys configured logger.warn("No server key URLs configured for " + serverConfig.getIssuer()); diff --git a/openid-connect-common/src/main/java/org/mitre/key/fetch/KeyFetcher.java b/openid-connect-common/src/main/java/org/mitre/key/fetch/KeyFetcher.java index 45cf39d15..62d65037e 100644 --- a/openid-connect-common/src/main/java/org/mitre/key/fetch/KeyFetcher.java +++ b/openid-connect-common/src/main/java/org/mitre/key/fetch/KeyFetcher.java @@ -54,13 +54,13 @@ public class KeyFetcher { return getArray; } - public PublicKey retrieveX509Key(OIDCServerConfiguration serverConfig) { + public PublicKey retrieveX509Key(String x509url) { PublicKey key = null; try { - InputStream x509Stream = restTemplate.getForObject(serverConfig.getX509SigningUrl(), InputStream.class); + InputStream x509Stream = restTemplate.getForObject(x509url, InputStream.class); CertificateFactory factory = CertificateFactory.getInstance("X.509"); X509Certificate cert = (X509Certificate) factory.generateCertificate(x509Stream); key = cert.getPublicKey(); @@ -73,11 +73,11 @@ public class KeyFetcher { return key; } - public PublicKey retrieveJwkKey(OIDCServerConfiguration serverConfig) { + public PublicKey retrieveJwkKey(String jwkUrl) { RSAPublicKey pub = null; try { - String jwkString = restTemplate.getForObject(serverConfig.getJwkSigningUrl(), String.class); + String jwkString = restTemplate.getForObject(jwkUrl, String.class); JsonObject json = (JsonObject) new JsonParser().parse(jwkString); JsonArray getArray = json.getAsJsonArray("keys"); for(int i = 0; i < getArray.size(); i++) {