I have to access one https rest web service(https://example.com) for which certificate has been provided by the client which contains 2 .cer files.
I have created
I had a similar problem:
@Bean("oAuth2")
public WebClient webOAuth2Client(ReactiveClientRegistrationRepository registration,
ServerOAuth2AuthorizedClientRepository clientRepository) {
ServerOAuth2AuthorizedClientExchangeFilterFunction filter =
new ServerOAuth2AuthorizedClientExchangeFilterFunction(
registration,
clientRepository);
filter.setDefaultClientRegistrationId("oAuth2");
return WebClient
.builder()
.filter(filter)
.build();
}
in property file something like:
security:
oauth2:
client:
provider:
oAuth2:
token-uri: url:port/auth/realms/SCRealm/protocol/openid-connect/token
registration:
oAuth2:
clientId: client_id
clientSecret: client_secret
authorizationGrantType: client_credentials
clientAuthenticationMethod: post
And in main application class :
System.setProperty("-Dio.netty.handler.ssl.noOpenSsl","true");
System.setProperty("javax.net.ssl.trustStore", "keyStore.jks");
System.setProperty("javax.net.ssl.trustStoreType", "JKS");
System.setProperty("javax.net.ssl.trustStorePassword", "any_strong_pass");