Skip to content

Comments

Add FTPS with SSL/TLS configuration#1516

Closed
YasanPunch wants to merge 68 commits intoballerina-platform:masterfrom
YasanPunch:ftps-update
Closed

Add FTPS with SSL/TLS configuration#1516
YasanPunch wants to merge 68 commits intoballerina-platform:masterfrom
YasanPunch:ftps-update

Conversation

@YasanPunch
Copy link
Contributor

@YasanPunch YasanPunch commented Dec 8, 2025

Purpose


Fixes: ballerina-platform/ballerina-library/#8489

Adds FTPS (FTP over SSL/TLS) support to the FTP module, enabling secure file transfers using SSL/TLS certificates.

Changes:

Added FTPS protocol option to the Protocol enum
Added SecureSocket configuration type for FTPS SSL/TLS settings
Added FtpsMode enum to support IMPLICIT and EXPLICIT FTPS modes

public enum Protocol {
    FTP = "ftp",
    FTPS = "ftps",  // New: Secure File Transfer Protocol
    SFTP = "sftp"
}

# FTPS connection mode
public enum FtpsMode {
    IMPLICIT,   // SSL/TLS established immediately (port 990)
    EXPLICIT    // Upgrades to SSL/TLS via AUTH TLS (port 21)
}

# Secure socket configuration for FTPS
public type SecureSocket record {|
    crypto:KeyStore key?;
    crypto:TrustStore trustStore?;
    FtpsMode mode = EXPLICIT;
|};

public type AuthConfiguration record {|
    ...
    SecureSocket secureSocket?;  // New: For FTPS protocol
|};

(Current) Usage Example:

ftp:ClientConfiguration ftpsConfig = {
    protocol: ftp:FTPS,
    host: "ftps.example.com",
    port: 21,
    auth: {
        credentials: {username: "user", password: "pass"},
        secureSocket: {
            key: {path: "client.p12", password: "keypass"},
            trustStore: {path: "truststore.p12", password: "trustpass"},
            mode: ftp:EXPLICIT
        }
    }
};

Future Enhancements (TODO):

  • Data channel protection level configuration (PROT P/C/S/E)
  • Hostname verification toggle for enhanced security
  • Test case development

Checklist

  • Linked to an issue
  • Updated the changelog
  • Added tests
  • Updated the spec
  • Checked native-image compatibility

@CLAassistant
Copy link

CLAassistant commented Dec 8, 2025

CLA assistant check
All committers have signed the CLA.

… 990 for IMPLICIT FTPS if unspecified. Improved KeyStore loading from Ballerina records and error handling for secure socket configurations.
…improved error handling for KeyStore loading, and added documentation regarding the limitations of hostname verification support in the current version of Apache Commons VFS2.
@codecov
Copy link

codecov bot commented Dec 10, 2025

Codecov Report

❌ Patch coverage is 7.43982% with 423 lines in your changes missing coverage. Please review.
✅ Project coverage is 19.01%. Comparing base (dec8c19) to head (c9b7c36).

Files with missing lines Patch % Lines
.../ftp/transport/server/util/FileTransportUtils.java 7.89% 132 Missing and 8 partials ⚠️
...java/io/ballerina/stdlib/ftp/client/FtpClient.java 15.62% 97 Missing and 11 partials ⚠️
...ballerina/stdlib/ftp/server/FtpListenerHelper.java 0.00% 102 Missing ⚠️
...ain/java/io/ballerina/stdlib/ftp/util/FtpUtil.java 1.88% 51 Missing and 1 partial ⚠️
...ftp/transport/server/RemoteFileSystemConsumer.java 0.00% 20 Missing ⚠️
...connector/contractimpl/VfsClientConnectorImpl.java 50.00% 0 Missing and 1 partial ⚠️

❌ Your project status has failed because the head coverage (19.01%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@              Coverage Diff              @@
##             master    #1516       +/-   ##
=============================================
- Coverage     81.17%   19.01%   -62.17%     
+ Complexity      509      243      -266     
=============================================
  Files            40       55       +15     
  Lines          2561     3518      +957     
  Branches        407      622      +215     
=============================================
- Hits           2079      669     -1410     
- Misses          319     2746     +2427     
+ Partials        163      103       -60     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…r implementations, as it is not supported by the current version of Apache Commons VFS2. Clean up related code and constants.
YasanPunch and others added 28 commits December 16, 2025 22:13
… 990 for IMPLICIT FTPS if unspecified. Improved KeyStore loading from Ballerina records and error handling for secure socket configurations.
…improved error handling for KeyStore loading, and added documentation regarding the limitations of hostname verification support.
…r implementations, as it is not supported by the current version of Apache Commons VFS2. Clean up related code and constants.
… configuration

- Introduced tests for FTPS client operations including explicit and implicit modes, file handling, and error scenarios.
- Added tests for FTPS listener functionality, ensuring correct event handling for file changes.
- Improved error handling for secure socket configurations in both client and server implementations.
- Updated mock server utilities to include FTPS server initialization for testing purposes.
… relevant files for consistency,

, remove hardcoded credentials and enhance password handling for improved security.
- Refactored test structure for better isolation and clarity.
- Introduced helper functions for state management and event handling.
- Improved file handling in tests, ensuring robust cleanup and setup.
- Updated mock server utilities to ensure isolated test environments for FTPS operations.
…ments

- Introduced a new configuration for testing the default port logic, ensuring that port 21 is correctly swapped to 990 for implicit mode.
- Added a cleanup function to manage test environment state after execution.
- Enhanced existing test cases to validate the new configuration and ensure robust error handling during FTPS operations.
- Updated the FTPS client test to use a more descriptive variable name for error handling.
- Increased the wait count in listener tests to ensure proper event detection.
- Improved error message clarity for invalid truststore scenarios in tests.
- Adjusted the FtpClient to default to port 990 when port 21 is specified for implicit FTPS mode.
@sonarqubecloud
Copy link

@YasanPunch YasanPunch closed this Dec 16, 2025
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.

Expose FTPS as separate protocol when connecting to FTP server

3 participants