Add hooks for outbound TLS start and close.#4377
Conversation
1fdf1ee to
c285281
Compare
|
[approve ci autest] |
7f0cb6a to
f5d5481
Compare
SolidWallOfCode
left a comment
There was a problem hiding this comment.
Does it matter if the close hook callback calls TSVConnReenable?
|
|
||
| .. default-domain:: c | ||
|
|
||
| TSNetConnect |
There was a problem hiding this comment.
Is this for TSNetConnect or TSNetInvokingContGet?
There was a problem hiding this comment.
Oops, copy error. Will update.
| ---------------------------- | ||
|
|
||
| This hook is invoked after ATS has connected to the upstream server and before the SSL handshake has started. This gives the plugin the option of | ||
| overriding the default SSL connections on the SSL object. |
There was a problem hiding this comment.
"default SSL connections"? Do you mean "connection options"?
There was a problem hiding this comment.
You are correct. Will update.
| @@ -834,7 +834,12 @@ void | |||
| SSLNetVConnection::do_io_close(int lerrno) | |||
| { | |||
| if (this->ssl != nullptr && sslHandShakeComplete) { | |||
There was a problem hiding this comment.
If the SSL handshake fails to complete, can it be the case that the START hook is called but not the CLOSE hook?
There was a problem hiding this comment.
Yes, as it stands that can be the case. Probably not a great thing. Will look into adding the hook invocation in the pre-handshake complete error cases.
|
I see the testing of whether the hooks are invoked, but it is not clear to me if we could alter the logic flow of the TLS handshake by manipulating the continuation. In #4013, I wanted to achieve this: AFTER OpenSSL verifies the server certificate against CA, inspect the server certificate using plugin-supplied function, and continue/terminate the TLS handshake based on the return value of the function. Can this implementation achieve the same? |
|
@CrendKing I think you want to look at PR #4414 and PR #4385. In that PR, you can set server.verify.policy to ENFORCED and server.verify.propoerties to SIGNATURE (ignoring the standard name requirements) and then register your plugin on the TS_SSL_VERIFY_SERVER_HOOK hook. If your plugin is invoked and is not pleased with the certificate, it can terminate the connection. I'll add a test for this case tomorrow in PR #4414. |
I read #4414, and I found this code is used to handle the hook I do not quite get how does the hook function from my plugin could alter the outcome of the OpenSSL verify function. The return value is not used, and I assume OpenSSL does not take ATS continuation into consideration in any way. Could you elaborate? |
f5d5481 to
dddca77
Compare
|
Updated to address @SolidWallOfCode's comments |
dddca77 to
9df0fd4
Compare
| @@ -0,0 +1,72 @@ | |||
| ''' | |||
| Test one delayed preaccept callback | |||
There was a problem hiding this comment.
Is this different from test 13? It has the same comment.
| It may be useful to delay the TLS handshake processing if other resources must be consulted to select or create | ||
| a certificate. | ||
|
|
||
| TS_VCONN_OUTBOUND_START_HOOK |
There was a problem hiding this comment.
TS_VCONN_OUTBOUND_START_HOOK - The use case I need to address requires that the plugin set the certificate used in the origin side TLS mutual auth, based on information that came in on client side request. This hook looks like it will be perfectly timed. 👍🏻
There was a problem hiding this comment.
Yes. that was our motivating use case as well.
98fb8a9 to
a9ae444
Compare
a9ae444 to
98ee1c0
Compare
|
A backport PR was created for 8.1.0 because of conflicts: #5237 |
Adds new hook points for plugins at the start and the close of an outbound TLS connection. Also adding two new Plugin APIs so the plugin can fetch the invoking Continuation or Transaction from the new outbound TLS connection.
The commit includes tests and documentation.
As this PR includes new APIs, I will send an API review email around.