Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6183195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:19:27+00:00 2026-05-24T01:19:27+00:00

I write FTPS server, and I have problems with ssl connection after AUTH TLS

  • 0

I write FTPS server, and I have problems with ssl connection after AUTH TLS command.
Simple example:

try
{
    int ServerPort = 21;
    ServerSocket FtpExServer = new ServerSocket(ServerPort);
    while(true)
    {
        Socket S = FtpExServer.accept();
        InputStreamReader ISR = new InputStreamReader(S.getInputStream());
        OutputStreamWriter OSW = new OutputStreamWriter(S.getOutputStream());
        BufferedReader ClientSocketReader = new BufferedReader(ISR);
        PrintWriter ClientSocketWriter = new PrintWriter(OSW, true);

        ClientSocketWriter.println("220 Welcome to FTP server.");
        print(ClientSocketReader.readLine());
        ClientSocketWriter.println("234 AUTH TLS successful");

        char[] passphrase = "pass".toCharArray();
        char[] cpassphrase = "cpass".toCharArray();
        KeyStore keystore = KeyStore.getInstance("JKS");
        keystore.load(new FileInputStream("keystore.jks"), passphrase);
        KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
        kmf.init(keystore, cpassphrase);
        SSLContext context = SSLContext.getInstance("TLS");
        KeyManager[] keyManagers = kmf.getKeyManagers();
        context.init(keyManagers, null, null);
        SSLServerSocketFactory ssf = context.getServerSocketFactory();

        SSLServerSocket ss = (SSLServerSocket) ssf.createServerSocket(990);
                ss.setSoTimeout(2000);          
                SSLSocket s = (SSLSocket)ss.accept();

        ISR = new InputStreamReader(s.getInputStream());
        OSW = new OutputStreamWriter(s.getOutputStream());
        ClientSocketReader = new BufferedReader(ISR);
        ClientSocketWriter = new PrintWriter(OSW, true);

        ClientSocketWriter.println("234 AUTH TLS successful");
        print(ClientSocketReader.readLine());
        ClientSocketWriter.println("331 Password required for smie");
        print(ClientSocketReader.readLine());
        ClientSocketWriter.println("230 User smie logged in");
        print(ClientSocketReader.readLine());
        ClientSocketWriter.println("215 UNIX Type: L8");
        print(ClientSocketReader.readLine());
        ClientSocketWriter.println("550 Command not suported.");
    }
}
catch(Exception e)
{
    print(e);
}

Description: FTP client(for example MoveITFreely) connect to server on port 21. After send command “AUTH TLS”, server send “234 AUTH TLS successful”. Now client must to connect to server on port 990(?), but client dont connect and get timeout exception.

What i do wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T01:19:28+00:00Added an answer on May 24, 2026 at 1:19 am

    There exist two methods to add SSL to FTP.

    First method is called implicit SSL. It means that the server is listening on port 990 and when the client connects to it, first SSL/TLS negotiation is performed, and then the established connection is used as a command channel for communication (for data channel SSL handshake is also performed in a similar manner).

    Second method is what you attempt to use. It’s called explicit SSL. The client connects on port 21, sends AUTH TLS and starts SSL negotiation on existing connection. Data channel can be secured or not secured depending on how you want it (you specify this using PROT command).

    You mixed the methods. I suggest that you read detailed explanation in Wikipedia before going further. Then read RFC for explicit TLS.

    Update: Also you’d need SSLClientSocket, not SSLServerSocket.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Write a class ListNode which has the following properties: int value; ListNode *next; Provide
I am trying to write a code that opens an FTP server on my
Write a function called swap which has a prototype of void swap (int&, int&);
Write a simple program that reads a line from the keyboard and outputs the
Write a program to simulate simple digital clock displaying HOURS(s) : MINUTES(s): SECOND(s) How
Write a C program to Delete a Tree. I have written a small snippet
Problem: Write a program Deal.java that takes an command-line argument N and prints N
Write code to determine if a number is divisible by 3. The input to
Write a program to determine whether a computer is big-endian or little-endian. bool endianness()
You write a function and, looking at the resulting assembly, you see it can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.