summaryrefslogtreecommitdiffstats
path: root/base/java-tools
diff options
context:
space:
mode:
Diffstat (limited to 'base/java-tools')
-rw-r--r--base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java56
1 files changed, 33 insertions, 23 deletions
diff --git a/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java b/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java
index 8a9f544c2..d5707d155 100644
--- a/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java
@@ -57,6 +57,8 @@ public class MainCLI extends CLI {
public Collection<Integer> rejectedCertStatuses;
public Collection<Integer> ignoredCertStatuses;
+ public File certDatabase;
+
public PKIClient client;
public PKIConnection connection;
public AccountClient accountClient;
@@ -328,33 +330,41 @@ public class MainCLI extends CLI {
if (verbose) System.out.println("Server URI: "+config.getServerURI());
- // initialize certificate database if specified
- if (config.getCertDatabase() != null) {
+ // initialize certificate database
+ if (config.getCertDatabase() == null) {
+ this.certDatabase = new File(
+ System.getProperty("user.home") + File.separator +
+ ".dogtag" + File.separator + "nssdb");
- try {
- if (verbose) System.out.println("Certificate database: "+config.getCertDatabase());
- CryptoManager.initialize(config.getCertDatabase());
-
- if (config.getPassword() != null) {
- try {
- CryptoManager manager = CryptoManager.getInstance();
- CryptoToken token = manager.getInternalKeyStorageToken();
- Password password = new Password(config.getPassword().toCharArray());
- token.login(password);
-
- } catch (IncorrectPasswordException e) {
- throw new Error("Incorrect certificate database password.", e);
- }
- }
+ } else {
+ this.certDatabase = new File(config.getCertDatabase());
+ }
- } catch (Throwable t) {
- if (verbose) {
- t.printStackTrace(System.err);
- } else {
- System.err.println(t.getClass().getSimpleName()+": "+t.getMessage());
+ certDatabase.mkdirs();
+
+ try {
+ if (verbose) System.out.println("Certificate database: "+certDatabase.getAbsolutePath());
+ CryptoManager.initialize(certDatabase.getAbsolutePath());
+
+ if (config.getPassword() != null) {
+ try {
+ CryptoManager manager = CryptoManager.getInstance();
+ CryptoToken token = manager.getInternalKeyStorageToken();
+ Password password = new Password(config.getPassword().toCharArray());
+ token.login(password);
+
+ } catch (IncorrectPasswordException e) {
+ throw new Error("Incorrect certificate database password.", e);
}
- System.exit(1);
}
+
+ } catch (Throwable t) {
+ if (verbose) {
+ t.printStackTrace(System.err);
+ } else {
+ System.err.println(t.getClass().getSimpleName()+": "+t.getMessage());
+ }
+ System.exit(1);
}
// execute command