test #135
@ -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.NoopHostnameVerifier;
|
||||||
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
|
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
|
||||||
import org.apache.hc.core5.ssl.SSLContexts;
|
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.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import com.hithomelabs.common.client.PortainerApiClient;
|
import com.hithomelabs.common.portainer.client.PortainerApiClient;
|
||||||
|
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
|
|
||||||
@ -22,7 +21,7 @@ public class PortainerClientConfig {
|
|||||||
@Bean
|
@Bean
|
||||||
public RestTemplate portainerRestTemplate() throws Exception {
|
public RestTemplate portainerRestTemplate() throws Exception {
|
||||||
SSLContext sslContext = SSLContexts.custom()
|
SSLContext sslContext = SSLContexts.custom()
|
||||||
.loadTrustMaterial(TrustAllStrategy.INSTANCE)
|
.loadTrustMaterial((chain, authType) -> true)
|
||||||
.build();
|
.build();
|
||||||
SSLConnectionSocketFactory sslSocketFactory =
|
SSLConnectionSocketFactory sslSocketFactory =
|
||||||
new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
|
new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
|
||||||
@ -36,6 +35,8 @@ public class PortainerClientConfig {
|
|||||||
@Bean
|
@Bean
|
||||||
public PortainerApiClient portainerApiClient(PortainerAutomationProperties props,
|
public PortainerApiClient portainerApiClient(PortainerAutomationProperties props,
|
||||||
RestTemplate portainerRestTemplate) {
|
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