-
Notifications
You must be signed in to change notification settings - Fork 4.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
advancedtls: add new module for advanced TLS handshaker #3187
Conversation
fc76a15
to
7c9f9a4
Compare
7c9f9a4
to
906d1f3
Compare
@jiangtaoli2016 Could you please take a first round of review on the API design? Thank you so much for the help! |
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.
Thanks Zhen for implementation! Looks very good. A few questions.
I have not reviewed the test file yet.
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.
Some minor comments on test.
serverRoot *x509.CertPool | ||
serverGetRoot func(rawConn net.Conn, rawCerts [][]byte) (*x509.CertPool, error) | ||
serverExpectError bool | ||
}{ |
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 may want to test the cases where the root CA certs do not match the peer certificates. E.g., server provides a valid certificate, but server's CA cert is different from client Root cert.
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.
Added the following test cases:
- Client_reload_both_certs_verifyFunc_Server_reload_both_certs_mutualTLS
- Client_wrong_peer_cert_Server_reload_both_certs_mutualTLS
- Client_wrong_trust_cert_Server_reload_both_certs_mutualTLS
- Client_reload_both_certs_verifyFunc_Server_wrong_peer_cert
- Client_reload_both_certs_verifyFunc_Server_wrong_trust_cert
In current implementation, client has to provide either RootCA or GetRootCA. We see use case grpc/grpc#20530 that client does not know root CA certs in advance. In that case, we give the power to client to validate via VerifyPeer function (since application can access target name and server certain chain). Thus, if client does not provide RootCA or GetRootCA, instead of failing, we just don't validate the server cert and let application decide via VerifyPeer. @ZhenLian Could update your implementation as well? |
128795a
to
781f1c0
Compare
Thanks @ZhenLian for the implementation. |
The API is now updated as: |
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.
Thanks for the PR. I left some comments in advancedtls.go
. I will review advancedtls_test.go
next.
74939ed
to
43d11d8
Compare
@cesarghali Thank you so much for the review! I left a few more comments. Please let me know if anything could be further improved :-) |
@cesarghali |
Friendly ping :-) |
d4ad63c
to
2e3e312
Compare
2e3e312
to
850dad9
Compare
35fa648
to
67ad997
Compare
@dfawley |
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 good overall, just some minor things.
f3c727d
to
aa767af
Compare
@dfawley |
aa767af
to
8d72f23
Compare
This PR contains the implementation and tests of a utility library for some advanced TLS features, including:
Credential Reloading: users are able to reload their credentials without restarting the app. Note that the "credential" here can be a private key, its corresponding certificate bundle, or trusted CA certificate bundle.
Server Authorization: on client side, we let users specify their own functions to check peers' identities when handshakes are finished. This feature is sometimes also referred to as "secure name checking" or "hostname verification".
There are some previous discussions in this deprecated PR: #3044. The goal of this PR remains the same, but change the APIs to provide better functionalities.
This PR includes the implementation and unit tests and integration tests for the client and server without credential reloading. Next PR will cover the integration tests for credential reloading.