Calling GnuPG in Java via a Runtime Process to encrypt and decrypt files - Decrypt always hangs

前端 未结 7 1514
隐瞒了意图╮
隐瞒了意图╮ 2021-01-18 16:25

NOTE: Coming back to this later as I\'ve been unable to find a working solution. Draining the input streams manually instead of using BufferedReaders doesn

7条回答
  •  深忆病人
    2021-01-18 16:49

    This may or may not be the problem (in the decrypt function)

        BufferedReader gpgOutput = new BufferedReader(new InputStreamReader(gpgProcess.getInputStream()));
        BufferedReader gpgErrorOutput = new BufferedReader(new InputStreamReader(gpgProcess.getInputStream()));
        BufferedWriter gpgInput = new BufferedWriter(new OutputStreamWriter(gpgProcess.getOutputStream()));
    

    You are wrapping the result of getInputStream twice. Obviously gpgErrorOutput should be wrapping the error stream, not the input stream.

提交回复
热议问题