Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package org.cloudfoundry.multiapps.controller.client.facade.util;

import java.net.MalformedURLException;
import java.net.Socket;
import java.net.URL;
import java.security.cert.X509Certificate;
import java.text.MessageFormat;

import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLException;
import javax.net.ssl.X509TrustManager;
import javax.net.ssl.X509ExtendedTrustManager;

import org.springframework.http.client.reactive.ClientHttpConnector;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
Expand All @@ -17,6 +19,7 @@

import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder;
import io.netty.handler.ssl.SslProvider;
import reactor.netty.http.client.HttpClient;

/**
Expand Down Expand Up @@ -72,15 +75,16 @@
private SslContext buildSslContext() {
try {
return SslContextBuilder.forClient()
.sslProvider(SslProvider.JDK)
.trustManager(createDummyTrustManager())
.build();
} catch (SSLException e) {
throw new RuntimeException("An error occurred setting up the SSLContext", e);
}
}

private X509TrustManager createDummyTrustManager() {
return new X509TrustManager() {
private X509ExtendedTrustManager createDummyTrustManager() {
return new X509ExtendedTrustManager() {

@Override
public void checkClientTrusted(X509Certificate[] xcs, String string) {
Expand All @@ -92,6 +96,26 @@
// NOSONAR
}

@Override
public void checkClientTrusted(X509Certificate[] xcs, String string, Socket socket) {

Check failure on line 100 in multiapps-controller-client/src/main/java/org/cloudfoundry/multiapps/controller/client/facade/util/RestUtil.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Enable server certificate validation on this SSL/TLS connection.

See more on https://sonarcloud.io/project/issues?id=cloudfoundry_multiapps-controller&issues=AaBDXosAWDblIGV2g-MG&open=AaBDXosAWDblIGV2g-MG&pullRequest=1903
Comment thread
theghost5800 marked this conversation as resolved.
Dismissed
// NOSONAR
}

@Override
public void checkServerTrusted(X509Certificate[] xcs, String string, Socket socket) {

Check failure on line 105 in multiapps-controller-client/src/main/java/org/cloudfoundry/multiapps/controller/client/facade/util/RestUtil.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Enable server certificate validation on this SSL/TLS connection.

See more on https://sonarcloud.io/project/issues?id=cloudfoundry_multiapps-controller&issues=AaBDXosAWDblIGV2g-MH&open=AaBDXosAWDblIGV2g-MH&pullRequest=1903
Comment thread
theghost5800 marked this conversation as resolved.
Dismissed
// NOSONAR
}

@Override
public void checkClientTrusted(X509Certificate[] xcs, String string, SSLEngine sslEngine) {

Check failure on line 110 in multiapps-controller-client/src/main/java/org/cloudfoundry/multiapps/controller/client/facade/util/RestUtil.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Enable server certificate validation on this SSL/TLS connection.

See more on https://sonarcloud.io/project/issues?id=cloudfoundry_multiapps-controller&issues=AaBDXosAWDblIGV2g-MI&open=AaBDXosAWDblIGV2g-MI&pullRequest=1903
Comment thread
theghost5800 marked this conversation as resolved.
Dismissed
// NOSONAR
}

@Override
public void checkServerTrusted(X509Certificate[] xcs, String string, SSLEngine sslEngine) {

Check failure on line 115 in multiapps-controller-client/src/main/java/org/cloudfoundry/multiapps/controller/client/facade/util/RestUtil.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Enable server certificate validation on this SSL/TLS connection.

See more on https://sonarcloud.io/project/issues?id=cloudfoundry_multiapps-controller&issues=AaBDXosAWDblIGV2g-MJ&open=AaBDXosAWDblIGV2g-MJ&pullRequest=1903
Comment thread
theghost5800 marked this conversation as resolved.
Dismissed
// NOSONAR
}

@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[] {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.cloudfoundry.multiapps.controller.client.facade.util.RestUtil;
import org.cloudfoundry.multiapps.controller.client.uaa.UAAClient;
import org.cloudfoundry.multiapps.controller.core.security.token.TokenService;
import org.cloudfoundry.multiapps.controller.core.util.ApplicationConfiguration;

@Named
public class OAuthClientFactory {
Expand All @@ -16,9 +17,11 @@
private TokenService tokenService;
@Inject
private UAAClient uaaClient;
@Inject

Check warning on line 20 in multiapps-controller-core/src/main/java/org/cloudfoundry/multiapps/controller/core/cf/OAuthClientFactory.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this field injection and use constructor injection instead.

See more on https://sonarcloud.io/project/issues?id=cloudfoundry_multiapps-controller&issues=AaBDXop-WDblIGV2g-MF&open=AaBDXop-WDblIGV2g-MF&pullRequest=1903
private ApplicationConfiguration configuration;

public OAuthClient createOAuthClient() {
return new OAuthClientExtended(uaaClient.getUaaUrl(), tokenService, restUtil.createWebClient(true));
return new OAuthClientExtended(uaaClient.getUaaUrl(), tokenService, restUtil.createWebClient(configuration.shouldSkipSslValidation()));
}

}
6 changes: 4 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
<liquibase.version>4.33.0</liquibase.version>
<liquibase-slf4j.version>5.1.0</liquibase-slf4j.version>
<cloudfoundry-client.version>5.16.0.RELEASE</cloudfoundry-client.version>
<reactor-netty.version>1.3.6</reactor-netty.version>
<netty.version>4.2.15.Final</netty.version>
<reactor-netty.version>1.3.7</reactor-netty.version>
<netty.version>4.2.17.Final</netty.version>
<swagger.version>1.6.16</swagger.version>
<jclouds.version>2.7.0</jclouds.version>
<guava.version>33.5.0-jre</guava.version>
Expand Down Expand Up @@ -292,6 +292,8 @@
<dependencyManagement>
<dependencies>
<dependency>
<!-- Force all Netty artifacts to 4.2.x to avoid JPMS split-package conflict
between netty-codec (4.1) and netty-codec-compression (4.2) on Java 25 -->
<groupId>io.netty</groupId>
<artifactId>netty-bom</artifactId>
<version>${netty.version}</version>
Expand Down
Loading