-
Notifications
You must be signed in to change notification settings - Fork 260
Adding a local version of google.p12 file #1625
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
Open
suryasoma
wants to merge
3
commits into
GoogleCloudDataproc:branch-3.1.x
Choose a base branch
from
suryasoma:branch-3.1.x
base: branch-3.1.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
|
@@ -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; | ||
|
|
@@ -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"; | ||
| private static final String KEYSTORE_PASSWORD = "notasecret"; | ||
|
|
||
| /** | ||
| * Create an {@link HttpTransport} with socketKeepAlive true | ||
|
|
@@ -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(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
|
||
Binary file not shown.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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.p12relative toHttpTransportFactory. is it verified?