]> WPIA git - gigi.git/blobdiff - tests/org/cacert/gigi/testUtils/ManagedTest.java
Implement testing of internal certificate issuing (and login with it)
[gigi.git] / tests / org / cacert / gigi / testUtils / ManagedTest.java
index 5f441d2b9185eb16fdebf9d12f1266fd85f0e827..2159a66322f002e709208907bd151367ee95d922 100644 (file)
@@ -284,4 +284,19 @@ public class ManagedTest {
                }
                return m.group(1);
        }
+
+       public static String[] generateCSR(String dn) throws IOException {
+               Process p = Runtime.getRuntime().exec(
+                       new String[] { "openssl", "req", "-newkey", "rsa:1024", "-nodes", "-subj", dn, "-config",
+                                       "keys/selfsign.config" });
+               String csr = IOUtils.readURL(new InputStreamReader(p.getInputStream()));
+
+               String[] parts = csr.split("(?<=-----)\n(?=-----)");
+               if (parts.length != 2) {
+                       System.err.println(IOUtils.readURL(new InputStreamReader(p.getErrorStream())));
+                       throw new Error();
+               }
+               return parts;
+       }
+
 }