diff options
author | alee <alee@c9f7a03b-bd48-0410-a16d-cbbf54688b0b> | 2009-04-28 20:32:11 +0000 |
---|---|---|
committer | alee <alee@c9f7a03b-bd48-0410-a16d-cbbf54688b0b> | 2009-04-28 20:32:11 +0000 |
commit | 7f8d26983c1be173df2754fef6053e63414d0803 (patch) | |
tree | 285e04eb65e724a9a98c2988c940dfc9792aede5 /pki/base/silent/src | |
parent | 8cf1a6ff98a3176ad4aacef1d98f285316631980 (diff) | |
download | pki-7f8d26983c1be173df2754fef6053e63414d0803.tar.gz pki-7f8d26983c1be173df2754fef6053e63414d0803.tar.xz pki-7f8d26983c1be173df2754fef6053e63414d0803.zip |
Bugzilla BZ 493418: silent install -save_p12 option creates file mode 644
git-svn-id: svn+ssh://svn.fedorahosted.org/svn/pki/trunk@418 c9f7a03b-bd48-0410-a16d-cbbf54688b0b
Diffstat (limited to 'pki/base/silent/src')
-rw-r--r-- | pki/base/silent/src/ca/ConfigureCA.java | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/pki/base/silent/src/ca/ConfigureCA.java b/pki/base/silent/src/ca/ConfigureCA.java index 70a0d9a98..a85768e99 100644 --- a/pki/base/silent/src/ca/ConfigureCA.java +++ b/pki/base/silent/src/ca/ConfigureCA.java @@ -103,6 +103,7 @@ public class ConfigureCA { public static String save_p12 = null; public static String backup_pwd = null; + public static String backup_fname = null; public static String ca_cert_name = null; public static String ca_cert_req = null; @@ -864,14 +865,24 @@ public class ConfigureCA { // dump hr.getResponseData() to file try { - FileOutputStream fos = new FileOutputStream("/tmp/tmp-ca.p12"); + FileOutputStream fos = new FileOutputStream(backup_fname); fos.write(hr.getResponseData()); fos.close(); + // set file to permissions 600 + String rtParams[] = { "chmod","600", backup_fname}; + Process proc = Runtime.getRuntime().exec(rtParams); + + BufferedReader br = new BufferedReader(new InputStreamReader(proc.getErrorStream())); + String line = null; + while ( (line = br.readLine()) != null) + System.out.println("Error: " + line); + int exitVal = proc.waitFor(); + // verify p12 file // Decode the P12 file - FileInputStream fis = new FileInputStream("/tmp/tmp-ca.p12"); + FileInputStream fis = new FileInputStream(backup_fname); PFX.Template pfxt = new PFX.Template(); PFX pfx = (PFX) pfxt.decode(new BufferedInputStream(fis, 2048)); @@ -1374,6 +1385,7 @@ public class ConfigureCA { StringHolder x_agent_name = new StringHolder(); StringHolder x_save_p12 = new StringHolder(); StringHolder x_backup_pwd = new StringHolder(); + StringHolder x_backup_fname = new StringHolder(); // separate key size for agent cert @@ -1449,6 +1461,7 @@ public class ConfigureCA { parser.addOption("-save_p12 %s #Enable/Disable p12 Export[true,false]", x_save_p12); parser.addOption("-backup_pwd %s #Backup Password for p12", x_backup_pwd); + parser.addOption("-backup_fname %s #Backup File for p12, default is /root/tmp-ca.p12", x_backup_fname); parser.addOption("-ca_sign_cert_subject_name %s #CA cert subject name", x_ca_sign_cert_subject_name); @@ -1525,6 +1538,11 @@ public class ConfigureCA { token_pwd = x_token_pwd.value; save_p12 = x_save_p12.value; backup_pwd = x_backup_pwd.value; + if ((x_backup_fname.value == null) || (x_backup_fname.equals(""))) { + backup_fname = "/root/tmp-ca.p12"; + } else { + backup_fname = x_backup_fname.value; + } agent_key_size = x_agent_key_size.value; agent_key_type = x_agent_key_type.value; |