forked from Hithomelabs/CFTunnels
Compare commits
No commits in common. "52f40e3d927aacef838414b0e3822223b6fc4f73" and "f1c9965396b5c9fcfaa68d1817df74f0ed2c5ac0" have entirely different histories.
52f40e3d92
...
f1c9965396
@ -22,11 +22,12 @@ import java.security.cert.X509Certificate;
|
|||||||
public class PortainerClientConfig {
|
public class PortainerClientConfig {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a RestTemplate that trusts all SSL certificates.
|
* Trust-all SSL RestTemplate for the "local" profile.
|
||||||
* Used when connecting via Cloudflare Tunnel (self-signed certs)
|
* Used when connecting via Cloudflare Tunnel (self-signed certs).
|
||||||
* or to the prod Portainer instance (also self-signed).
|
|
||||||
*/
|
*/
|
||||||
private static RestTemplate buildTrustAllRestTemplate() throws Exception {
|
@Profile("local")
|
||||||
|
@Bean(name = "portainerRestTemplate")
|
||||||
|
public RestTemplate portainerRestTemplateLocal() throws Exception {
|
||||||
TrustManager[] trustAllCerts = new TrustManager[]{
|
TrustManager[] trustAllCerts = new TrustManager[]{
|
||||||
new X509TrustManager() {
|
new X509TrustManager() {
|
||||||
public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; }
|
public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; }
|
||||||
@ -46,32 +47,12 @@ public class PortainerClientConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trust-all SSL RestTemplate for the "local" profile.
|
* Standard validating SSL RestTemplate for non-local profiles
|
||||||
* Used when connecting via Cloudflare Tunnel (self-signed certs).
|
* (CI, test, prod — internal Docker network).
|
||||||
*/
|
*/
|
||||||
@Profile("local")
|
@Profile("!local")
|
||||||
@Bean(name = "portainerRestTemplate")
|
@Bean(name = "portainerRestTemplate")
|
||||||
public RestTemplate portainerRestTemplateLocal() throws Exception {
|
public RestTemplate portainerRestTemplate() {
|
||||||
return buildTrustAllRestTemplate();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Trust-all SSL RestTemplate for the "prod" profile.
|
|
||||||
* Prod Portainer at https://192.168.0.100:9443 uses a self-signed certificate.
|
|
||||||
*/
|
|
||||||
@Profile("prod")
|
|
||||||
@Bean(name = "portainerRestTemplate")
|
|
||||||
public RestTemplate portainerRestTemplateProd() throws Exception {
|
|
||||||
return buildTrustAllRestTemplate();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Standard validating SSL RestTemplate for profiles other than local and prod
|
|
||||||
* (CI, test — internal Docker network with valid certs).
|
|
||||||
*/
|
|
||||||
@Profile("!local & !prod")
|
|
||||||
@Bean(name = "portainerRestTemplate")
|
|
||||||
public RestTemplate portainerRestTemplateDefault() {
|
|
||||||
return new RestTemplate();
|
return new RestTemplate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user