forked from Hithomelabs/CFTunnels
88: Fix PortainerApiClient import/constructor, replace TrustAllStrategy with lambda
This commit is contained in:
parent
d0e1ea938f
commit
93e9baa5d4
@ -6,13 +6,12 @@ import org.apache.hc.client5.http.io.HttpClientConnectionManager;
|
||||
import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
|
||||
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
|
||||
import org.apache.hc.core5.ssl.SSLContexts;
|
||||
import org.apache.hc.core5.ssl.TrustAllStrategy;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import com.hithomelabs.common.client.PortainerApiClient;
|
||||
import com.hithomelabs.common.portainer.client.PortainerApiClient;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
|
||||
@ -22,7 +21,7 @@ public class PortainerClientConfig {
|
||||
@Bean
|
||||
public RestTemplate portainerRestTemplate() throws Exception {
|
||||
SSLContext sslContext = SSLContexts.custom()
|
||||
.loadTrustMaterial(TrustAllStrategy.INSTANCE)
|
||||
.loadTrustMaterial((chain, authType) -> true)
|
||||
.build();
|
||||
SSLConnectionSocketFactory sslSocketFactory =
|
||||
new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
|
||||
@ -36,6 +35,8 @@ public class PortainerClientConfig {
|
||||
@Bean
|
||||
public PortainerApiClient portainerApiClient(PortainerAutomationProperties props,
|
||||
RestTemplate portainerRestTemplate) {
|
||||
return new PortainerApiClient(props.getBaseUrl(), props.getApiKey(), portainerRestTemplate);
|
||||
PortainerApiClient client = new PortainerApiClient(portainerRestTemplate, props.getBaseUrl());
|
||||
client.authenticateWithApiKey(props.getApiKey());
|
||||
return client;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user