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

feat: add mtls support for NetHttpTransport #1147

Merged
merged 17 commits into from
Oct 30, 2020
Merged

feat: add mtls support for NetHttpTransport #1147

merged 17 commits into from
Oct 30, 2020

Conversation

arithmetic1728
Copy link
Contributor

@arithmetic1728 arithmetic1728 commented Oct 15, 2020

go/java-apiary-client-mtls (section 2.2.2.1)

Support
(1) passing keystore to SslContext constructor for client certificate and private key.
(2) creating keystore from certAndKey input stream.

Summary of new functions:

// In google-http-client/src/main/java/com/google/api/client/util/SecurityUtils.java
// create mtls key store from client cert and key input stream
public static KeyStore createMtlsKeyStore(InputStream certAndKey)

// In google-http-client/src/main/java/com/google/api/client/util/SslUtils.java
// init sslcontext with trust store and mtls key store
public static SSLContext initSslContext(
      SSLContext sslContext,
      KeyStore trustStore,
      TrustManagerFactory trustManagerFactory,
      KeyStore mtlsKeyStore,
      String mtlsKeystorePassword,
      KeyManagerFactory keyManagerFactory)

// In google-http-client/src/main/java/com/google/api/client/http/javanet/NetHttpTransport.java
public Builder trustCertificates(
        KeyStore trustStore, KeyStore mtlsKeyStore, String mtlsKeystorePassword)

// Indict if transport is mtls.
public boolean isMtls() {
    return this.isMtls;
}
``

@arithmetic1728 arithmetic1728 requested a review from a team as a code owner October 15, 2020 18:52
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Oct 15, 2020
Copy link
Collaborator

@chingor13 chingor13 left a comment

Choose a reason for hiding this comment

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

We also need to add tests for this

@arithmetic1728
Copy link
Contributor Author

We also need to add tests for this

Tests are added now.

Copy link
Collaborator

@chingor13 chingor13 left a comment

Choose a reason for hiding this comment

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

We're going to hold off on approving and merging this approach (especially the isMtls() accessor) until the whole design is complete and approved.

@chingor13 chingor13 added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Oct 16, 2020
Copy link
Collaborator

@chingor13 chingor13 left a comment

Choose a reason for hiding this comment

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

Looking really close.

@chingor13 chingor13 changed the title feat: support keystore in transport for mtls feat: add mtls support for NetHttpTransport Oct 27, 2020
Copy link
Contributor

@elharo elharo left a comment

Choose a reason for hiding this comment

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

For open source projects like this one, it's very helpful to have designs and issues on Github rather than in corp.

@chanseokoh
Copy link
Contributor

Looks like this is to enable mutual TLS for NetHttpTransport. How about #904 (ApacheHttpTransport)? Is it that #904 should eventually be fixed?

@chingor13
Copy link
Collaborator

MTLS support will also need to be implemented for the Apache transport as well.

@arithmetic1728
Copy link
Contributor Author

For open source projects like this one, it's very helpful to have designs and issues on Github rather than in corp.

I added a summary of the new functions added, I think they are self explanatory. The design doc is for client libs, http client is just a building block.

@arithmetic1728
Copy link
Contributor Author

Looks like this is to enable mutual TLS for NetHttpTransport. How about #904 (ApacheHttpTransport)? Is it that #904 should eventually be fixed?

yes, mTLS support will be added to apache transport.

Copy link
Collaborator

@chingor13 chingor13 left a comment

Choose a reason for hiding this comment

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

A few nits

arithmetic1728 and others added 7 commits October 29, 2020 10:38
…vanet/NetHttpTransport.java

Co-authored-by: Jeff Ching <chingor@google.com>
…vanet/NetHttpTransport.java

Co-authored-by: Jeff Ching <chingor@google.com>
…lUtils.java

Co-authored-by: Jeff Ching <chingor@google.com>
…lUtils.java

Co-authored-by: Jeff Ching <chingor@google.com>
…curityUtilsTest.java

Co-authored-by: Jeff Ching <chingor@google.com>
…lUtils.java

Co-authored-by: Jeff Ching <chingor@google.com>
@chingor13
Copy link
Collaborator

@arithmetic1728 Let's follow up with a PR to add @Beta annotations to the new APIs and @since 1.38 to the javadoc of the new APIs

@chingor13 chingor13 merged commit 51762f2 into googleapis:master Oct 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement. do not merge Indicates a pull request not ready for merge, due to either quality or timing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants