Skip to content

Conversation

@ramaraochavali
Copy link
Contributor

@ramaraochavali ramaraochavali commented Oct 10, 2017

Please refer to issue for more details

@grpc-kokoro
Copy link

Thanks for your pull request. The automated tests will run as soon as one of the admins verifies this change is ok for us to run on our infrastructure.

@ramaraochavali ramaraochavali changed the title added ssl related methods for ManagedChannelBuilder Added ssl related methods for ManagedChannelBuilder Oct 10, 2017
@ramaraochavali ramaraochavali changed the title Added ssl related methods for ManagedChannelBuilder SSL Related Methods in ManagedChannelBuilder Oct 13, 2017
* @throws SSLException
*/
@Override
public NettyChannelBuilder trustStore(File trustCertCollectionFile) throws SSLException {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

May have to add keyManager also here. But am waiting for your approval on the pattern. then will add support keyManager if needed

Copy link
Member

Choose a reason for hiding this comment

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

I'm not excited that this builds the sslContext all at once, as it means it can't be combined with any other TLS configuration (like keyManager). Although I'm also not excited about adding keyManager to ManagedChannelBuilder; it's a fairly advanced use case and needs extra configuration on server-side as well (like request/require client certs and trust store). Going down this road feels like we end up re-inventing our own TLS context for configuration.

I think I'd be happier with a useTransportSecurity(File trustCerts). But I have reservations about it as well as I feel it is dangerously close to opening a can of worms for other TLS configuration. And at the same time I'm not too bothered by the status quo of needing to use a specific builder when managing your own CA.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. Should I ignore this then?

*
* @return this
* @throws UnsupportedOperationException if transport security is not supported.
*/
Copy link
Member

Choose a reason for hiding this comment

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

Any new methods added to ManagedChannelBuilder must have a default implementation here, otherwise it breaks API stability. Just implement the throwing UnsupportOperationException here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok. will add

* @throws SSLException
*/
@Override
public NettyChannelBuilder trustStore(File trustCertCollectionFile) throws SSLException {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not excited that this builds the sslContext all at once, as it means it can't be combined with any other TLS configuration (like keyManager). Although I'm also not excited about adding keyManager to ManagedChannelBuilder; it's a fairly advanced use case and needs extra configuration on server-side as well (like request/require client certs and trust store). Going down this road feels like we end up re-inventing our own TLS context for configuration.

I think I'd be happier with a useTransportSecurity(File trustCerts). But I have reservations about it as well as I feel it is dangerously close to opening a can of worms for other TLS configuration. And at the same time I'm not too bothered by the status quo of needing to use a specific builder when managing your own CA.

@ramaraochavali
Copy link
Contributor Author

should I just ignore the changes of trustStore and just restrict it to useTransportSecurity()

@thelinuxfoundation
Copy link

Thank you for your pull request. Before we can look at your contribution, we need to ensure all contributors are covered by a Contributor License Agreement.

After the following items are addressed, please respond with a new comment here, and the automated system will re-verify.

Regards,
The Linux Foundation CLA GitHub bot

@ejona86
Copy link
Member

ejona86 commented Nov 8, 2017

should I just ignore the changes of trustStore and just restrict it to useTransportSecurity()

@ramaraochavali, that seems good to me. A change with just useTransportSecurity() would be easy to get in.

Signed-off-by: Rama <ramaraochavali@gmail.com>
@ramaraochavali ramaraochavali changed the title SSL Related Methods in ManagedChannelBuilder Add useTransportSecurity in ManagedChannelBuilder Nov 9, 2017
@ramaraochavali
Copy link
Contributor Author

@ejona86 I removed the rest of the stuff and only retained the useTransportSecurity method.

Copy link
Member

@ejona86 ejona86 left a comment

Choose a reason for hiding this comment

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

Looks pretty good. Only minor stuff left.

import io.grpc.internal.ConnectionClientTransport;
import io.grpc.internal.GrpcUtil;
import io.grpc.internal.SharedResourceHolder;

Copy link
Member

Choose a reason for hiding this comment

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

We only put extra line between static and non-static imports. Remove here and elsewhere.

}

@Override
public Builder useTransportSecurity() {
Copy link
Member

Choose a reason for hiding this comment

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

This and several other of the implementations seem unnecessary, now that ManagedChannelBuilder. provides a default.

GrpcSslContexts.ensureAlpnAndH2Enabled(sslContext.applicationProtocolNegotiator());
}
this.sslContext = sslContext;
this.negotiationType = NegotiationType.TLS;
Copy link
Member

Choose a reason for hiding this comment

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

While I see the value in this, doing things implicitly can lead to trouble. We mostly try to have the builder be "dumb setters." Since I'm conflicted on this, let's just leave it out for now.

*
* @return this
* @throws UnsupportedOperationException if transport security is not supported.
*/
Copy link
Member

Choose a reason for hiding this comment

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

We mark new APIs with @ExperimentalApi("https://link/to/github/issue"). Create a new issue for this API to become stable and add it as part of the annotation here.

@ejona86
Copy link
Member

ejona86 commented Nov 9, 2017

okay to test

@ejona86
Copy link
Member

ejona86 commented Nov 9, 2017

@ramaraochavali, Soo, since you started this we've swapped CLAs from Google's to CNCF. Would you be willing to go through the process again with the Linux Foundation?

(I'm working on getting the Google CLA GitHub status removed for new PRs.)

@ramaraochavali
Copy link
Contributor Author

@ejona86 addressed review comments and signed with CNCF Linux foundation. Please check

@ejona86 ejona86 added the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Nov 10, 2017
@kokoro-team kokoro-team removed the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Nov 10, 2017
Copy link
Member

@ejona86 ejona86 left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks!

@ejona86 ejona86 requested a review from dapengzhang0 November 10, 2017 18:17
* Makes the client use TLS.
*
* @return this
* @throws UnsupportedOperationException if transport security is not supported.
Copy link
Contributor

Choose a reason for hiding this comment

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

also adding * @since 1.9.0 in the doc would be nice

Copy link
Member

Choose a reason for hiding this comment

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

Done. I went ahead and did that.

@ejona86 ejona86 added the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Nov 10, 2017
@kokoro-team kokoro-team removed the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Nov 10, 2017
@ejona86 ejona86 merged commit 17e1ad9 into grpc:master Nov 10, 2017
@ramaraochavali ramaraochavali deleted the feature/uniform-ssl-context branch November 14, 2017 16:16
@zhangkun83 zhangkun83 added this to the 1.9 milestone Jan 9, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants