ProcessBuilder and running OpenSSL command which contains spaces

后端 未结 1 1235
无人共我
无人共我 2020-12-21 11:26

I am facing a problem while executing openSSL command using my jar in Ubuntu environemnt. I have concluded that this is happening because of the space in the path of the fil

相关标签:
1条回答
  • 2020-12-21 12:12
    cmdGetAlgorithm[0] = "openssl x509 -in";
    ...
    

    As @immibis stated in the comments, arg[0] is the program name. So the vector should look something like:

    cmdArg[0] = "/usr/local/ssl/bin/openssl";
    cmdArg[1] = "x509";
    cmdArg[2] = "-in";
    cmdArg[3] = certFilePAth;
    cmdArg[4] = "-noout"
    cmdArg[5] = "-text";
    cmdArg[6] = "-certopt";
    cmdArg[7] = "no_subject,no_header,no_version,no_serial,no_validity," +
                "no_issuer,no_pubkey,no_sigdump,no_aux,no_extensions ";
    

    You should always specify the complete filename of the executable to ensure you are running the intended executable, and not something planted by an adversary.

    0 讨论(0)
提交回复
热议问题