Skip to content

Conversation

Pandiyarajk
Copy link

This commit addresses issue #576 where Unix curl FTP uploads over SSL/TLS resulted in corrupted zip files. The root cause was premature SSL shutdown during active data transfers.

Problem:
When OpenSSL.SSL.ZeroReturnError occurred in SSLConnection.recv() during an active file transfer, the connection would immediately close via super().handle_close(), causing incomplete file writes and corruption.

Solution:
Modified SSLConnection.recv() to defer connection closure when a file transfer is in progress. If file_obj exists (indicating active transfer), the method returns b'' instead of closing the connection immediately.

Changes:

  • Modified SSLConnection.recv() to check for active file transfers before closing on SSL.ZeroReturnError
  • Added TLS_DTPHandler.close() override to ensure proper SSL shutdown
  • Cleaned up incorrect SSL buffer handling in FTPHandler.on_file_received()

Testing:
The fix prevents premature SSL shutdown during file transfers while maintaining proper connection cleanup after transfer completion. This resolves the specific corruption issue reported in #576.

Note: This addresses the SSL-specific corruption issue. Broader 0-byte transfer problems observed during testing are separate and require additional investigation.

…ve mode

This commit addresses issue giampaolo#576 where Unix curl FTP uploads over SSL/TLS resulted in corrupted zip files. The root cause was premature SSL shutdown during active data transfers.

**Problem:**
When `OpenSSL.SSL.ZeroReturnError` occurred in `SSLConnection.recv()` during
an active file transfer, the connection would immediately close via
`super().handle_close()`, causing incomplete file writes and corruption.

**Solution:**
Modified `SSLConnection.recv()` to defer connection closure when a file
transfer is in progress. If `file_obj` exists (indicating active transfer),
the method returns `b''` instead of closing the connection immediately.

**Changes:**
- Modified `SSLConnection.recv()` to check for active file transfers before
  closing on `SSL.ZeroReturnError`
- Added `TLS_DTPHandler.close()` override to ensure proper SSL shutdown
- Cleaned up incorrect SSL buffer handling in `FTPHandler.on_file_received()`

**Testing:**
The fix prevents premature SSL shutdown during file transfers while maintaining
proper connection cleanup after transfer completion. This resolves the specific
corruption issue reported in giampaolo#576.

Note: This addresses the SSL-specific corruption issue. Broader 0-byte transfer
problems observed during testing are separate and require additional investigation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant