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 as a code owner Oct 15, 2020
@google-cla google-cla bot added the cla: yes label Oct 15, 2020
Copy link
Collaborator

@chingor13 chingor13 left a comment

We also need to add tests for this

@arithmetic1728
Copy link
Contributor Author

@arithmetic1728 arithmetic1728 commented Oct 16, 2020

We also need to add tests for this

Tests are added now.

Copy link
Collaborator

@chingor13 chingor13 left a comment

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 label Oct 16, 2020
Copy link
Collaborator

@chingor13 chingor13 left a comment

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
Collaborator

@elharo elharo left a comment

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

@chanseokoh chanseokoh commented Oct 27, 2020

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

@chingor13 chingor13 commented Oct 27, 2020

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

@arithmetic1728
Copy link
Contributor Author

@arithmetic1728 arithmetic1728 commented Oct 27, 2020

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

@arithmetic1728 arithmetic1728 commented Oct 27, 2020

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.

arithmetic1728 and others added 7 commits Oct 29, 2020
…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

@chingor13 chingor13 commented Oct 30, 2020

@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
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes do not merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants