-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Jib is not sending client certificate regardless of the javax.net.ssl.keyStore
property.
#2585
Comments
I'm not familiar with keystore stuff. Perhaps @chanseokoh can take a look when's back from vacation. |
Ok, no problem. To give you a little bit extra information: when private static HttpTransport getSecureHttpTransport() {
// Do not use NetHttpTransport. It does not process response errors properly.
// See https://github.com/google/google-http-java-client/issues/39
//
// A new ApacheHttpTransport needs to be created for each connection because otherwise HTTP
// connection persistence causes the connection to throw NoHttpResponseException.
return new ApacheHttpTransport();
} When public static HttpClientBuilder newDefaultHttpClientBuilder() {
return HttpClientBuilder.create()
.useSystemProperties()
.setSSLSocketFactory(SSLConnectionSocketFactory.getSocketFactory()) // <--- this is the problem
.setMaxConnTotal(200)
.setMaxConnPerRoute(20)
.setConnectionTimeToLive(-1, TimeUnit.MILLISECONDS)
.setRoutePlanner(new SystemDefaultRoutePlanner(ProxySelector.getDefault()))
.disableRedirectHandling()
.disableAutomaticRetries();
}
The problem with using getSocketFactory()The method looks like this: public static SSLConnectionSocketFactory getSocketFactory() throws SSLInitializationException {
return new SSLConnectionSocketFactory(SSLContexts.createDefault(), getDefaultHostnameVerifier());
} Whenever this public static SSLContext createDefault() throws SSLInitializationException {
try {
final SSLContext sslContext = SSLContext.getInstance(SSLContextBuilder.TLS);
sslContext.init(null, null, null);
return sslContext;
} catch (final NoSuchAlgorithmException ex) {
throw new SSLInitializationException(ex.getMessage(), ex);
} catch (final KeyManagementException ex) {
throw new SSLInitializationException(ex.getMessage(), ex);
}
} The first parameter of The solution by using
|
@jacksierkstra thanks for the very detailed information. I do remember the context, but your comment saved me a lot of time. We can certainly overcome this limitation on the Jib side; I will merge #2592 soon. However, I still have the general question why Google HTTP Client doesn't use the system socket factory by default (I assume it has a reason) and whether it should switch the default, as I don't think I have the expertise to answer these questions. What's your thoughts? |
That is, should Google HTTP Client fix googleapis/google-http-java-client#904 on their side as well? |
I was reading this exact issue that you are referring to as well and I am not really sure as to why they are using the My guess is that they want to make sure that the |
I am not sure if there is anything to be fixed on their side. They provide both |
That's true. However, I know the default Google HTTP Client honors the other system property |
My pleasure :). |
Fixed by #2592. |
@jacksierkstra we released Jib Gradle 2.5.0 and Jib Maven 2.5.2 with the fix. Thanks for your contribution! Let us know if it still doesn't work. |
Thank you for the notification, I will let you know if something is not working. |
Just in case, we've patched Jib Maven (patches unrelated to this issue), so the latest is 2.5.2. (OTOH, the latest for Jib Gradle is 2.5.0.) |
They fixed googleapis/google-http-java-client#904. I don't know how they fixed it, but we might be able to remove what we did on our end (#2592) after upgrading the Google HTTP Client? |
Environment:
Description of the issue:
The issue has been filed before, but in googleapis/google-http-java-client#904 (comment). The problem is that whenever you add the jvm property: javax.net.ssl.keyStore, it is not picked up by the eventual HttpClient.
I did some research and it seems that
org.apache.http.conn.ssl.SSLConnectionSocketFactory#getSocketFactory()
is always called whenever the plugin is constructing a HttpClient. Iforg.apache.http.conn.ssl.SSLConnectionSocketFactory#getSystemSocketFactory()
would be called, the property: javax.net.ssl.keyStore would be taken into consideration and therefore mutual SSL authentication would be possible.The problem is that
org.apache.http.ssl.SSLContexts#createDefault()
is always constructing anSSLContext
without a keymanager and/or trustmanager and that makes mutual SSL impossible.Expected behavior:
Whenever I set the property: javax.net.ssl.keyStore, I expect that the keystore would be set on the
SSLContext
.Steps to reproduce:
mvn -Djavax.net.debug=ssl,handshake -Djavax.net.ssl.keyStore=/path/to/keystore -Djavax.net.ssl.keyStorePassword=changeit jib:build
The text was updated successfully, but these errors were encountered: