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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@ That will output XML that looks like this:

To use a custom HTTP client with this helper library, please see the [advanced example of how to do so](./advanced-examples/custom-http-client.md).

The default HTTP client refuses TLS connections whose certificate chain contains one of eight intermediate certificates with compromised keys (CVE-2026-111943). A client built from your own `HttpClientBuilder` doesn't get this check unless you set `DistrustedIntermediates.createConnectionManager()` as its connection manager, as the [advanced example](./advanced-examples/custom-http-client.md#keep-the-distrusted-intermediate-check) shows.

## Docker image

The `Dockerfile` present in this repository and its respective `twilio/twilio-java` Docker image are currently used by Twilio for testing purposes only.
Expand Down
8 changes: 7 additions & 1 deletion advanced-examples/custom-http-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ However, within the helper library, there is an implementation of `com.twilio.ht
Now that we understand how all the components fit together, we can create our own `TwilioRestClient` that can connect through a proxy server. To make this reusable, here’s a class that you can use to create this `TwilioRestClient` whenever you need one:

```java
import com.twilio.http.DistrustedIntermediates;
import com.twilio.http.HttpClient;
import com.twilio.http.NetworkHttpClient;
import com.twilio.http.TwilioRestClient;
Expand Down Expand Up @@ -123,7 +124,8 @@ public class ProxiedTwilioClientCreator {
.setConnectTimeout(Timeout.ofMilliseconds(10000))
.build();

PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
// Refuse certificate chains that contain a distrusted intermediate, as the default client does.
PoolingHttpClientConnectionManager connectionManager = DistrustedIntermediates.createConnectionManager();
connectionManager.setDefaultMaxPerRoute(10);
connectionManager.setMaxTotal(10 * 2);

Expand Down Expand Up @@ -157,6 +159,10 @@ public class ProxiedTwilioClientCreator {
}
```

### Keep the distrusted-intermediate check

The default `NetworkHttpClient` refuses TLS connections whose certificate chain contains one of eight intermediate certificates with compromised keys (CVE-2026-111943, the same list Go distrusts as of Go 1.27.3 and 1.26.10). A client built from your own `HttpClientBuilder` only gets this check if it uses `DistrustedIntermediates.createConnectionManager()` as its connection manager, as the example above does.

In this example, we use some environment variables loaded at the program startup to retrieve various configuration settings:

- Your Twilio Account Sid and Auth Token (found here, in the Twilio console)
Expand Down
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,12 @@
<version>3.16.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp-tls</artifactId>
<version>5.2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down
Loading
Loading