Why is the NSS PK12UTIL that is being called from a java process reporting bad database?

StackOverflow https://stackoverflow.com/questions/13730049

  •  05-12-2021
  •  | 
  •  

Question

I do the following:

File tmpDir = com.google.common.io.Files.createTempDir();
tmpDir.deleteOnExit();

// determine command based upon OS
String prefix = "pk12util";
String command = String.format(
            "-i %s -d sql:%s -W '' -K ''", 
            cert.getAbsolutePath(), tmpDir.getAbsolutePath());

// run the command
CommandRunner.run(prefix, command);

CommandRunner is a wrapper around the java ProcessBuilder. It handles creating the process, returning command output and exit status.

Here is the command being run from the java process and the corresponding output.

pk12util -i a-typical-tls-cert.p12 -d sql:/tmpdirpath -W '' -K ''

pk12util: function failed: security library: bad database.

When I copy and paste the command I am running from the java process it completes successfully. I verified permissions on the certdir. I even tried running the -N on the tmpDir which yields no resolution. Anyone have any suggestions? I tried to dig through the source code for the pk12util for the error but couldn't find anything pertinent.

Was it helpful?

Solution

I am not sure if anyone else will be doing this but I solved the issue by modifying my CommandRunner from using the ProcessBuilder to use using the Runtime.getRuntime().exec(command). I don't understand why the process builder was failing versus the runtime#exec.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top