-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Add useTransportSecurity in ManagedChannelBuilder #3561
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
Add useTransportSecurity in ManagedChannelBuilder #3561
Conversation
|
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. |
| * @throws SSLException | ||
| */ | ||
| @Override | ||
| public NettyChannelBuilder trustStore(File trustCertCollectionFile) throws SSLException { |
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.
May have to add keyManager also here. But am waiting for your approval on the pattern. then will add support keyManager if needed
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.
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.
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.
Ok. Should I ignore this then?
| * | ||
| * @return this | ||
| * @throws UnsupportedOperationException if transport security is not supported. | ||
| */ |
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.
Any new methods added to ManagedChannelBuilder must have a default implementation here, otherwise it breaks API stability. Just implement the throwing UnsupportOperationException here.
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.
ok. will add
| * @throws SSLException | ||
| */ | ||
| @Override | ||
| public NettyChannelBuilder trustStore(File trustCertCollectionFile) throws SSLException { |
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.
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.
|
should I just ignore the changes of trustStore and just restrict it to useTransportSecurity() |
|
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, |
@ramaraochavali, that seems good to me. A change with just useTransportSecurity() would be easy to get in. |
Signed-off-by: Rama <ramaraochavali@gmail.com>
|
@ejona86 I removed the rest of the stuff and only retained the |
ejona86
left a comment
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.
Looks pretty good. Only minor stuff left.
| import io.grpc.internal.ConnectionClientTransport; | ||
| import io.grpc.internal.GrpcUtil; | ||
| import io.grpc.internal.SharedResourceHolder; | ||
|
|
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.
We only put extra line between static and non-static imports. Remove here and elsewhere.
| } | ||
|
|
||
| @Override | ||
| public Builder useTransportSecurity() { |
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.
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; |
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.
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. | ||
| */ |
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.
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.
|
okay to test |
|
@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.) |
|
@ejona86 addressed review comments and signed with CNCF Linux foundation. Please check |
ejona86
left a comment
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.
Looks great! Thanks!
| * Makes the client use TLS. | ||
| * | ||
| * @return this | ||
| * @throws UnsupportedOperationException if transport security is not supported. |
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.
also adding * @since 1.9.0 in the doc would be nice
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.
Done. I went ahead and did that.
Please refer to issue for more details