首页 > 解决方案 > 如何从客户端发送的服务器解密文件

问题描述

我有以下家庭作业项目。需要使用 ftps 创建 server-client 并将文件上传到服务器。在上传文件之前必须加密。另一端的服务器,在收到加密文件后,解密文件。我卡在这里。

我在这里使用第一个回复加密了文件最简单的方法来加密java中的文本文件(使用DES)并将文件发送到服务器。服务器接收文件但它接收到加密(显然)。我读了一些关于 ssl 自动解密的信息,但我该如何设置呢?任何帮助将非常感激。

    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();

标签: javasslftps

解决方案


推荐阅读