shwstppr opened a new pull request, #11503:
URL: https://github.com/apache/cloudstack/pull/11503

   ### Description
   
   This pull request refactors the TLS framing and buffer management in the 
`Link` class to improve correctness and maintainability, and updates the SSL 
context initialization to use TLS 1.3 for enhanced security. CloudStack uses a 
4-byte header for TLS packets. Earlier, it was not sent within the TLS 
application data, which affected maintainability and the implementation of 
agent-server communication using a different language. The most important 
changes are grouped below.
   
   #### TLS Framing and Buffer Management
   
   * Reworked the TLS buffer handling in `Link.java`, replacing legacy header 
and packet assembly logic with a more robust system using `netBuffer`, 
`appBuffer`, and an explicit `headerBuffer` for frame length management. This 
improves frame parsing and avoids buffer overflows.
   * Refactored the read and write logic: the `read` method now correctly 
assembles frames from TLS streams, handling buffer resizing and edge cases, 
while the `doWrite` method builds TLS packets with a 4-byte length header and 
payload, ensuring correct framing and handshake handling.
   * Simplified the message sending and writing logic by removing manual header 
prepending and using the new framing system; the write queue now contains only 
payload buffers, and the header is added during the TLS wrap process.
   
   #### Security Improvements
   
   * Updated SSL context initialization in `Link.java` to use 
`SSLUtils.getSSLContextWithLatestVersion()`, ensuring that TLS 1.3 is used for 
all server, client, and management SSL contexts.
   * Added a new method `getSSLContextWithLatestVersion()` in `SSLUtils.java`, 
which returns an `SSLContext` instance for TLS 1.3.
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing 
functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [ ] Bug fix (non-breaking change which fixes an issue)
   - [x] Enhancement (improves an existing feature and functionality)
   - [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
   - [ ] build/CI
   - [ ] test (unit or integration test code)
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Feature/Enhancement Scale
   
   - [ ] Major
   - [ ] Minor
   
   #### Bug Severity
   
   - [ ] BLOCKER
   - [ ] Critical
   - [ ] Major
   - [ ] Minor
   - [ ] Trivial
   
   ### Screenshots (if appropriate):
   
   ### How Has This Been Tested?
   
   <!-- Please describe in detail how you tested your changes. -->
   <!-- Include details of your testing environment, and the tests you ran to 
-->
   
   #### How did you try to break this feature and the system with this change?
   
   <!-- see how your change affects other areas of the code, etc. -->
   
   <!-- Please read the 
[CONTRIBUTING](https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md) 
document -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to