title: Why is the NSS PK12UTIL that is being called from a java process reporting bad database?
body: <p>I do the following:</p>
  
  <pre><code>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);
  </code></pre>
  
  <p>CommandRunner is a wrapper around the java ProcessBuilder. It handles creating the process, returning command output and exit status. </p>
  
  <p>Here is the command being run from the java process and the corresponding output.</p>
  
  <blockquote>
    <p>pk12util -i a-typical-tls-cert.p12 -d sql:/tmpdirpath -W '' -K ''</p>
    
    <p>pk12util: function failed: security library: bad database.</p>
  </blockquote>
  
  <p>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. </p>