1

I have the following project for homework. Need to create server-client with ftps and upload file to the server. Before uploading the file must be encrypted.The server from the other side, upon receiving the encrypted file, decrypt the file.I'm stuck here.

I encrypted the file using first reply here Simplest way to encrypt a text file in java (with DES) and sent file to the server.Server receives the file but it receives it encrypted(obviously). I read some about that ssl does decryption automatically but how do I set it? Any help would be much appreciated.

    Server:
    this.factory.setPort(port);
    this.ssl.setKeystoreFile(this.getKeystore());
    this.ssl.setKeystorePassword("password");

    this.factory.setSslConfiguration(ssl.createSslConfiguration());
    this.factory.setImplicitSsl(true);

    this.serverFactory.addListener("default", 
    factory.createListener());

    this.userManagerFactory.setFile(new File("user.properties"));


    this.serverFactory.setUserManager
    (userManagerFactory.createUserManager());
    this.server = serverFactory.createServer();
    this.server.start();

     Client:
        ftpsClient.connect(server,port);
        ftpsClient.login(user,pass);
        ftpsClient.enterLocalPassiveMode();
        ftpsClient.type(FTP.BINARY_FILE_TYPE);

        File firstLocalFile =encryptFile();

        String firstRemoteFile = "test.txt";

        InputStream is = new FileInputStream(firstLocalFile);

        ftpsClient.storeFile(firstRemoteFile, is);


        is.close();
        ftpsClient.logout();
        ftpsClient.disconnect();
  • The data are transparently encrypted and decrypted if you use SSL/TLS (and thus usually also with FTPS). If instead you should manually encrypt the file before upload then it somehow needs to be manually decrypted by the receiver, i.e. TLS decrypts only the data encrypted by TLS and not any encryption done outside of TLS. It is unclear though what your actual requirement are: uploaded encrypted (TLS is sufficient, it encrypts **during** upload) or encrypt **before** upload (needs to be manually decrypted **after** upload was done, not handled by TLS). – Steffen Ullrich Jun 15 '19 at 11:49
  • Client uses standard FTP commands to upload a file. Before upload of a file, the client encrypts the file, preserving both, encrypted and plain file. The server from the other side, upon receiving the encrypted file, decrypt the file. Encryption of the file is entirely your choice. Thats the requirement. – Qni Mihailov Jun 15 '19 at 11:55
  • In this case you need to have some access to the server in order to explicitly decrypt there. It is totally unknown what kind of access you have so it is unclear what you can use for decryption and when and how to invoke the decryption. – Steffen Ullrich Jun 15 '19 at 14:21
  • Well I was thinking the same. Basically my server is what I posted as a code. Been searching for any way to get access to the uploading file but couldn't find one ;( Do you have other suggestion how should I approach ? – Qni Mihailov Jun 15 '19 at 14:27

0 Answers0