Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WFLY-20032] adds sslcontext, which trusts any cert, to thread-racing… #986

Merged
merged 1 commit into from
Dec 4, 2024
Merged
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
2 changes: 1 addition & 1 deletion thread-racing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client-api</artifactId>
<artifactId>resteasy-client</artifactId>
<type>jar</type>
<scope>provided</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@
import org.jboss.as.quickstarts.threadracing.stage.RaceStage;

import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.client.WebTarget;
import jakarta.ws.rs.core.Response;

import java.security.SecureRandom;
import java.util.Map;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.client.jaxrs.engines.PassthroughTrustManager;

import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;

/**
* The Jakarta REST race stage implements the race's boxes, which a racer uses to do a pit stop.
Expand All @@ -49,8 +54,15 @@ public void run(Race.Registration registration) throws Exception {
.append("/pitStop")
.toString();
// create and setup the new standard Jakarta REST client (and its web target)
final Client client = ((ResteasyClientBuilder) ClientBuilder.newBuilder())
.build();
// please note that it uses a custom SSLContext that trusts any certificate, this should not be used on production
final SSLContext sslContext = SSLContext.getInstance("SSL");
sslContext.init(
null,
new TrustManager[] { new PassthroughTrustManager() },
new SecureRandom());
final Client client = ResteasyClientBuilder.newBuilder()
.sslContext(sslContext)
.build();
try {
final WebTarget target = client.target(pitStopURI);
// get current time
Expand Down
Loading