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
11 changes: 11 additions & 0 deletions util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,15 @@
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>**/*.p12</exclude>
</excludes>
</resource>
</resources>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.api.client.googleapis.GoogleUtils;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.util.SecurityUtils;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.flogger.GoogleLogger;
import java.io.IOException;
Expand All @@ -37,6 +38,7 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.security.GeneralSecurityException;
import java.security.KeyStore;
import java.time.Duration;
import javax.annotation.Nullable;
import javax.net.ssl.HttpsURLConnection;
Expand All @@ -45,6 +47,8 @@
/** Factory for creating HttpTransport types. */
public class HttpTransportFactory {
private static final GoogleLogger logger = GoogleLogger.forEnclosingClass();
private static final String KEYSTORE_FILE_NAME = "google.p12";
Copy link
Contributor

@singhravidutt singhravidutt Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given it is going to be used just one it's fine to jsut hardcode it.

Also, we need to package the google.p12 relative to HttpTransportFactory. is it verified?

private static final String KEYSTORE_PASSWORD = "notasecret";

/**
* Create an {@link HttpTransport} with socketKeepAlive true
Expand Down Expand Up @@ -166,8 +170,18 @@ && getRequestingPort() == proxyUri.getPort()) {
static NetHttpTransport.Builder createNetHttpTransportBuilder(
@Nullable URI proxyUri, @Nullable Duration readTimeout)
throws IOException, GeneralSecurityException {
NetHttpTransport.Builder builder =
new NetHttpTransport.Builder().trustCertificates(GoogleUtils.getCertificateTrustStore());

KeyStore keyStore = SecurityUtils.getPkcs12KeyStore();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blast radius of it could be huge, does it make sense to put this change behind a flag and slowly deprecate it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

try (InputStream fis =
HttpTransportFactory.class.getClassLoader().getResourceAsStream(KEYSTORE_FILE_NAME)) {
if (fis == null) {
logger.atWarning().log("Error reading " + KEYSTORE_FILE_NAME + " file from resources.");
keyStore = GoogleUtils.getCertificateTrustStore();
} else {
keyStore.load(fis, KEYSTORE_PASSWORD.toCharArray());
}
}
NetHttpTransport.Builder builder = new NetHttpTransport.Builder().trustCertificates(keyStore);
SSLSocketFactory wrappedSslSocketFactory =
requireNonNullElseGet(
builder.getSslSocketFactory(), HttpsURLConnection::getDefaultSSLSocketFactory);
Expand Down
Binary file added util/src/main/resources/google.p12
Binary file not shown.