Skip to content

Commit 00faecf

Browse files
Merge pull request #1140 from cloudfoundry/boot-2-5
Changes to SSLContext setup to handle deprecations in reactor-netty &…
2 parents 2879b44 + 67a834e commit 00faecf

File tree

4 files changed

+23
-11
lines changed

4 files changed

+23
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ bin/
88
.classpath
99
.settings/
1010
.factorypath
11+
.gradle

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The `cf-java-client` project is a Java language binding for interacting with a C
1515
* `cloudfoundry-operations` – An API and implementation that corresponds to the [Cloud Foundry CLI][c] operations. This project builds on the `cloudfoundry-client` and therefore has a single implementation.
1616

1717
## Versions
18-
The Cloud Foundry Java Client has two active versions. The `5.x` line uses Spring Boot `2.4.x` just to manage its dependencies, while the `4.x` line uses Spring Boot `2.3.x`.
18+
The Cloud Foundry Java Client has two active versions. The `5.x` line is compatible with Spring Boot `2.4.x - 2.6.x` just to manage its dependencies, while the `4.x` line uses Spring Boot `2.3.x`.
1919

2020
## Dependencies
2121
Most projects will need two dependencies; the Operations API and an implementation of the Client API. For Maven, the dependencies would be defined like this:
@@ -25,12 +25,12 @@ Most projects will need two dependencies; the Operations API and an implementati
2525
<dependency>
2626
<groupId>org.cloudfoundry</groupId>
2727
<artifactId>cloudfoundry-client-reactor</artifactId>
28-
<version>5.0.0.RELEASE</version>
28+
<version>latest.RELEASE</version>
2929
</dependency>
3030
<dependency>
3131
<groupId>org.cloudfoundry</groupId>
3232
<artifactId>cloudfoundry-operations</artifactId>
33-
<version>5.0.0.RELEASE</version>
33+
<version>latest.RELEASE</version>
3434
</dependency>
3535
...
3636
</dependencies>
@@ -56,8 +56,8 @@ For Gradle, the dependencies would be defined like this:
5656

5757
```groovy
5858
dependencies {
59-
compile 'org.cloudfoundry:cloudfoundry-client-reactor:5.0.0.RELEASE'
60-
compile 'org.cloudfoundry:cloudfoundry-operations:5.0.0.RELEASE'
59+
compile 'org.cloudfoundry:cloudfoundry-client-reactor:<latest>.RELEASE'
60+
compile 'org.cloudfoundry:cloudfoundry-operations:<latest>.RELEASE'
6161
...
6262
}
6363
```

cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/_DefaultConnectionContext.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import javax.management.JMException;
4444
import javax.management.MalformedObjectNameException;
4545
import javax.management.ObjectName;
46+
import javax.net.ssl.SSLException;
4647
import javax.net.ssl.TrustManagerFactory;
4748
import java.lang.management.ManagementFactory;
4849
import java.time.Duration;
@@ -283,12 +284,16 @@ private HttpClient configureProxy(HttpClient client) {
283284
.orElse(client);
284285
}
285286

286-
private void configureSsl(SslProvider.SslContextSpec ssl) {
287-
SslProvider.Builder builder = ssl.sslContext(createSslContextBuilder()).defaultConfiguration(DefaultConfigurationType.TCP);
287+
private void configureSsl(SslProvider.SslContextSpec ssl){
288+
try{
289+
SslProvider.Builder builder = ssl.sslContext(createSslContextBuilder().build());
288290

289-
getSslCloseNotifyReadTimeout().ifPresent(builder::closeNotifyReadTimeout);
290-
getSslHandshakeTimeout().ifPresent(builder::handshakeTimeout);
291-
getSslCloseNotifyFlushTimeout().ifPresent(builder::closeNotifyFlushTimeout);
291+
getSslCloseNotifyReadTimeout().ifPresent(builder::closeNotifyReadTimeout);
292+
getSslHandshakeTimeout().ifPresent(builder::handshakeTimeout);
293+
getSslCloseNotifyFlushTimeout().ifPresent(builder::closeNotifyFlushTimeout);
294+
} catch (SSLException e) {
295+
this.logger.error("Unable to configure SSL", e);
296+
}
292297
}
293298

294299
private HttpClient createHttpClient() {

cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/util/DefaultSslCertificateTruster.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@
2020
import org.cloudfoundry.reactor.ProxyConfiguration;
2121
import org.slf4j.Logger;
2222
import org.slf4j.LoggerFactory;
23+
import reactor.core.Exceptions;
2324
import reactor.core.publisher.Mono;
2425
import reactor.netty.resources.LoopResources;
2526
import reactor.netty.tcp.SslProvider.SslContextSpec;
2627
import reactor.netty.tcp.TcpClient;
2728
import reactor.util.function.Tuple2;
2829
import reactor.util.function.Tuples;
2930

31+
import javax.net.ssl.SSLException;
3032
import javax.net.ssl.TrustManager;
3133
import javax.net.ssl.TrustManagerFactory;
3234
import javax.net.ssl.X509TrustManager;
@@ -120,7 +122,11 @@ private static KeyStore addToTrustStore(X509Certificate[] untrustedCertificates,
120122
}
121123

122124
private static void configureSsl(SslContextSpec sslContextSpec, CertificateCollectingTrustManager collector) {
123-
sslContextSpec.sslContext(SslContextBuilder.forClient().trustManager(new StaticTrustManagerFactory(collector)));
125+
try {
126+
sslContextSpec.sslContext(SslContextBuilder.forClient().trustManager(new StaticTrustManagerFactory(collector)).build());
127+
} catch (SSLException e) {
128+
throw Exceptions.propagate(e);
129+
}
124130
}
125131

126132
private static TcpClient getTcpClient(Optional<ProxyConfiguration> proxyConfiguration, LoopResources threadPool, CertificateCollectingTrustManager collector, String host, int port) {

0 commit comments

Comments
 (0)