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
NIFI-7468 Updated SSLSocketChannel to support TLS 1.3 #5152
Conversation
039b125
to
6359e99
Compare
- Handling additional FINISHED Handshake Status for TLS 1.3 Post-Handshake Messages per RFC 8446 Section 4.6 - Removed clearing buffers after handshake to avoid losing packets - Updated read() method to check Handshake Status after SSLEngine.unwrap() - Changed SSLSocketChannelSender to close SSLSocketChannel before other resources - Added ChannelStatus enum and convenience logging methods for tracing status - Added unit tests for TLS 1.2 and 1.3 using Netty server and client handlers
6359e99
to
7401d21
Compare
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.
Tested with PutTCP/ListenTCP, works smoothly with TLSv1.3. I feel the updated code is more readable, and the trace log statements are a great addition for any future gotchas. I don't have any issues with the code, so I'm a +1.
Thanks for the review and verification @gresockj! |
@gresockj Did you test using Java 8 or 11 (or both)? |
Only 8. I'll try 11 tomorrow |
Will test this out |
+1, changes look good. I tested this in a 2 node secure cluster with a S2S and PostHTTP and ListenHTTP using RestrictedSSLContext for TLS 1.2 and TLS 1.3 using Java 8 (Zulu 1.8.0_292-b10) and Java 11 (11.0.10+9-LTS) at run time. Also tested PutTCP/ListenTCP with TLS 1.3 and Java 11 (11.0.10+9-LTS). |
@exceptionfactory did you say the DistributedMapCacheClient should benefit from this fix? I just tried a flow with DetectDuplicate using DistributedMapCacheClient configured with a RestrictedSSLContext on TLS 1.3 (Java 11.0.11+9-LTS), and got the following exception:
This only occurred once at the very beginning of processing ~100,000 flow files, and with a retry, it was successful. |
@gresockj The Thanks for noting that problem, the updated I corrected the |
Thanks for the update, @exceptionfactory! This appears to have resolved the issue. |
Tested again, nothing more from me. Merging. |
- Handling additional FINISHED Handshake Status for TLS 1.3 Post-Handshake Messages per RFC 8446 Section 4.6 - Removed clearing buffers after handshake to avoid losing packets - Updated read() method to check Handshake Status after SSLEngine.unwrap() - Changed SSLSocketChannelSender to close SSLSocketChannel before other resources - Added ChannelStatus enum and convenience logging methods for tracing status - Added unit tests for TLS 1.2 and 1.3 using Netty server and client handlers NIFI-8704 Updated netty-handler to 4.1.65.Final NIFI-7468 Corrected SSLSocketChannel.read() to return byte read NIFI-7468 Adjusted comment formatting Signed-off-by: Nathan Gough <thenatog@gmail.com> This closes apache#5152.
- Handling additional FINISHED Handshake Status for TLS 1.3 Post-Handshake Messages per RFC 8446 Section 4.6 - Removed clearing buffers after handshake to avoid losing packets - Updated read() method to check Handshake Status after SSLEngine.unwrap() - Changed SSLSocketChannelSender to close SSLSocketChannel before other resources - Added ChannelStatus enum and convenience logging methods for tracing status - Added unit tests for TLS 1.2 and 1.3 using Netty server and client handlers NIFI-8704 Updated netty-handler to 4.1.65.Final NIFI-7468 Corrected SSLSocketChannel.read() to return byte read NIFI-7468 Adjusted comment formatting Signed-off-by: Nathan Gough <thenatog@gmail.com> This closes apache#5152.
- Handling additional FINISHED Handshake Status for TLS 1.3 Post-Handshake Messages per RFC 8446 Section 4.6 - Removed clearing buffers after handshake to avoid losing packets - Updated read() method to check Handshake Status after SSLEngine.unwrap() - Changed SSLSocketChannelSender to close SSLSocketChannel before other resources - Added ChannelStatus enum and convenience logging methods for tracing status - Added unit tests for TLS 1.2 and 1.3 using Netty server and client handlers NIFI-8704 Updated netty-handler to 4.1.65.Final NIFI-7468 Corrected SSLSocketChannel.read() to return byte read NIFI-7468 Adjusted comment formatting Signed-off-by: Nathan Gough <thenatog@gmail.com> This closes apache#5152.
Description of PR
NIFI-7468 Resolves several issues with
SSLSocketChannel
handshake processing in order to work with TLS 1.3.SSLSocketChannel
includes custom handling ofjavax.net.ssl.SSLEngine
, which did not respond properly to Post-Handshake Messages in TLS 1.3, described in RFC 8446 Section 4.6. TheSSLSocketChannel.connect()
method was clearing stream and application buffers after completing the TLS handshake, resulting in the loss of Post-Handshake messages as well as network packets. This loss of data resulted in exceptions suchTag mismatch
under both TLS 1.2 and TLS 1.3 when using AES-GCM cipher suites.The
SSLSocketChannelSender.close()
method was also closing the connectedSocketChannel
, resulting inSSLSocketChannel
being unable to process TLS close notify messages.NIFI-7468 introduces a private
ChannelStatus
enum and convenience logging methods to support detailed logging at theTRACE
level when necessary. Logs and exception messages now include both the remote address and remote port number to improve troubleshooting options.The new
SSLSocketChannelTest
leverages a TLS server and client using the Netty framework to verify expected behavior for both TLS 1.2 and 1.3. Unit testing and runtime testing of TLS 1.3 requires either Java 11, or a version of Java 8 with update 272 or higher.These changes address issues with several processors, including as
ListenTCP
andPutTCP
, as well as Distributed Cache Clients running with TLS.In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
For all changes:
Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
Has your PR been rebased against the latest commit within the target branch (typically
main
)?Is your initial contribution a single, squashed commit? Additional commits in response to PR reviewer feedback should be made on this branch and pushed to allow change tracking. Do not
squash
or use--force
when pushing to allow for clean monitoring of changes.For code changes:
mvn -Pcontrib-check clean install
at the rootnifi
folder?LICENSE
file, including the mainLICENSE
file undernifi-assembly
?NOTICE
file, including the mainNOTICE
file found undernifi-assembly
?.displayName
in addition to .name (programmatic access) for each of the new properties?For documentation related changes:
Note:
Please ensure that once the PR is submitted, you check GitHub Actions CI for build issues and submit an update to your PR as soon as possible.