我正在尝试将我的 Spring Cloud Feign Client 设置为使用自定义 HostnameVerifier。我需要自定义 HostnameVerifier 来忽略证书问题。我怎样才能做到这一点?
这是我当前的配置:
@FeignClient(name = "AccountSettingsClient", url = "${account.settings.service.url}", decode404 = true,
configuration = AccountSettingsClientConfig.class, fallbackFactory = AccountSettingsClientFallbackFactory.class)
public interface AccountSettingsClient {
@RequestMapping(method = RequestMethod.GET, value = "/settings/{uuid}")
AccountSettings accountSettings(@PathVariable("uuid") String uuid);
}
@Component
@Slf4j
class AccountSettingsClientFallbackFactory implements FallbackFactory<AccountSettingsClient> {
@Override
public AccountSettingsClient create(Throwable cause) {
return uuid -> {
log.warn("Falling back to null.", cause);
return null;
};
}
}
@Configuration
@RequiredArgsConstructor
@EnableConfigurationProperties(SomeProperties.class)
@EnableFeignClients
public class AccountSettingsClientConfig {
private final SomeProperties someProperties;
@Bean
RequestInterceptor oauth2FeignRequestInterceptor() {
return new OAuth2FeignRequestInterceptor(new
DefaultOAuth2ClientContext(), resource());
}
}