Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot
 public class Tester {   public static void main(String[] args) {   String[] cmd = {   "/bin/sh",   "-c",   "keytool",   "-genkey",   "-dname",   "\"C=US,CN=CU,L=ABC,O=ABC_Univ,OU=ABC_Pro\"",   "-keysize",   "1024",   "-alias",   "testkeypairs",   "-keyalg",   "RSA",   "-sigalg",   "SHA1withRSA",   "-keystore",   "testkeystore",   "-storepass",   "abcdef",   "-keypass",   "abcdef"   }   Process testProc = Runtime.getRuntime().exec(cmd); } 

}

There is no error when I ran it. But it did not give me the keystore. My questions are:

  1. The certificate generated by keytool is not considered as the "subprocess's output" which needs to be fed to the parent process using getinputstream()getinputstream(), is it?

  2. If it is, I also tried the getinputstream()getinputstream() thing as discussed in the following post,

 http://stackoverflow.com/questions/8308148/keytool-usage-with-runtime-getruntime-exec-under-linux 

Keytool usage with Runtime.getRuntime().exec() under Linux

public class Tester { public static void main(String[] args) { String[] cmd = { "/bin/sh", "-c", "keytool", "-genkey", "-dname", "\"C=US,CN=CU,L=ABC,O=ABC_Univ,OU=ABC_Pro\"", "-keysize", "1024", "-alias", "testkeypairs", "-keyalg", "RSA", "-sigalg", "SHA1withRSA", "-keystore", "testkeystore", "-storepass", "abcdef", "-keypass", "abcdef" } Process testProc = Runtime.getRuntime().exec(cmd); 

}

There is no error when I ran it. But it did not give me the keystore. My questions are:

  1. The certificate generated by keytool is not considered as the "subprocess's output" which needs to be fed to the parent process using getinputstream(), is it?

  2. If it is, I also tried the getinputstream() thing as discussed in the following post,

 http://stackoverflow.com/questions/8308148/keytool-usage-with-runtime-getruntime-exec-under-linux 
 public class Tester {   public static void main(String[] args) {   String[] cmd = {   "/bin/sh",   "-c",   "keytool",   "-genkey",   "-dname",   "\"C=US,CN=CU,L=ABC,O=ABC_Univ,OU=ABC_Pro\"",   "-keysize",   "1024",   "-alias",   "testkeypairs",   "-keyalg",   "RSA",   "-sigalg",   "SHA1withRSA",   "-keystore",   "testkeystore",   "-storepass",   "abcdef",   "-keypass",   "abcdef"   }   Process testProc = Runtime.getRuntime().exec(cmd); } 

There is no error when I ran it. But it did not give me the keystore. My questions are:

  1. The certificate generated by keytool is not considered as the "subprocess's output" which needs to be fed to the parent process using getinputstream(), is it?

  2. If it is, I also tried the getinputstream() thing as discussed in the following post,

Keytool usage with Runtime.getRuntime().exec() under Linux

deleted 1 characters in body
Source Link
Amy Yu
  • 23
  • 1
  • 7

I'd like to create a self-signed certificate by invoking keytool in my java script. Here is a simplified version of my code which includes the problem I have:

public class Tester { public static void main(String[] args) { String[] cmd = { "/bin/sh", "-c", "keytool", "-genkey", "-dname", "\"C=US,CN=CU,L=ABC,O=ABC_Univ,OU=ABC_Pro\"", "-keysize", "1024", "-alias", "testkeypairs", "-keyalg", "RSA", "-sigalg", "SHA1withRSA", "-keystore", "testkeystore", "-storepass", "abcdef", "-keypass", "abcdef" } Process testProc = Runtime.getRuntime().exec(cmd); 

}

There is no error when I ran it. But it did not give me the keystore. My questions are:

  1. The certificate generated by keytool is not considered as the "subprocess's output" which needs to be fed to the parent process using getinputstream(), is it?

  2. If it is, I also tried the getinputstream() thing as discussed in the following post,

<\pre> Keytool usage with Runtime.getRuntime().exec() under Linux

 http://stackoverflow.com/questions/8308148/keytool-usage-with-runtime-getruntime-exec-under-linux 

the program just got stuck and seems to never stop.

  1. Is there any other ways to create self-signed certificate using java program?

I am a newbie in Java and English is not my first language. I hope I have expressed my question clearly.

I'd like to create a self-signed certificate by invoking keytool in my java script. Here is a simplified version of my code which includes the problem I have:

public class Tester { public static void main(String[] args) { String[] cmd = { "/bin/sh", "-c", "keytool", "-genkey", "-dname", "\"C=US,CN=CU,L=ABC,O=ABC_Univ,OU=ABC_Pro\"", "-keysize", "1024", "-alias", "testkeypairs", "-keyalg", "RSA", "-sigalg", "SHA1withRSA", "-keystore", "testkeystore", "-storepass", "abcdef", "-keypass", "abcdef" } Process testProc = Runtime.getRuntime().exec(cmd); 

}

There is no error when I ran it. But it did not give me the keystore. My questions are:

  1. The certificate generated by keytool is not considered as the "subprocess's output" which needs to be fed to the parent process using getinputstream(), is it?

  2. If it is, I also tried the getinputstream() thing as discussed in the following post,

<\pre> Keytool usage with Runtime.getRuntime().exec() under Linux

the program just got stuck and seems to never stop.

  1. Is there any other ways to create self-signed certificate using java program?

I am a newbie in Java and English is not my first language. I hope I have expressed my question clearly.

I'd like to create a self-signed certificate by invoking keytool in my java script. Here is a simplified version of my code which includes the problem I have:

public class Tester { public static void main(String[] args) { String[] cmd = { "/bin/sh", "-c", "keytool", "-genkey", "-dname", "\"C=US,CN=CU,L=ABC,O=ABC_Univ,OU=ABC_Pro\"", "-keysize", "1024", "-alias", "testkeypairs", "-keyalg", "RSA", "-sigalg", "SHA1withRSA", "-keystore", "testkeystore", "-storepass", "abcdef", "-keypass", "abcdef" } Process testProc = Runtime.getRuntime().exec(cmd); 

}

There is no error when I ran it. But it did not give me the keystore. My questions are:

  1. The certificate generated by keytool is not considered as the "subprocess's output" which needs to be fed to the parent process using getinputstream(), is it?

  2. If it is, I also tried the getinputstream() thing as discussed in the following post,

 http://stackoverflow.com/questions/8308148/keytool-usage-with-runtime-getruntime-exec-under-linux 

the program just got stuck and seems to never stop.

  1. Is there any other ways to create self-signed certificate using java program?

I am a newbie in Java and English is not my first language. I hope I have expressed my question clearly.

Source Link
Amy Yu
  • 23
  • 1
  • 7
Loading