private static GigiPreparedStatement finishJob;
- private static boolean running = true;
+ private static volatile boolean running = true;
private static Thread runner;
runSigner();
}
- public synchronized static void stopSigner() throws InterruptedException {
- if (runner == null) {
- throw new IllegalStateException("already stopped");
+ public static void stopSigner() throws InterruptedException {
+ Thread capturedRunner;
+ synchronized (SimpleSigner.class) {
+ if (runner == null) {
+ throw new IllegalStateException("already stopped");
+ }
+ capturedRunner = runner;
+ running = false;
+ SimpleSigner.class.notifyAll();
}
- running = false;
- runner.interrupt();
- runner.join();
- runner = null;
+ capturedRunner.join();
}
public synchronized static void runSigner() throws SQLException, IOException, InterruptedException {
runner.start();
}
- private static void work() {
+ private synchronized static void work() {
try {
gencrl();
} catch (IOException e2) {
} catch (InterruptedException e2) {
e2.printStackTrace();
}
+
while (running) {
try {
signCertificates();
revokeCertificates();
- Thread.sleep(5000);
+
+ SimpleSigner.class.wait(5000);
} catch (IOException e) {
e.printStackTrace();
} catch (SQLException e) {
} catch (InterruptedException e1) {
}
}
+ runner = null;
}
private static void revokeCertificates() throws SQLException, IOException, InterruptedException {
subj.put("CN", "<empty>");
System.out.println("WARNING: DN was empty");
}
- String[] call = new String[] {
- "openssl", "ca",//
- "-in",
- "../../" + csrname,//
- "-cert",
- "../" + ca + ".crt",//
- "-keyfile",
- "../" + ca + ".key",//
- "-out",
- "../../" + crt.getPath(),//
- "-utf8",
- "-startdate",
- sdf.format(fromDate),//
- "-enddate",
- sdf.format(toDate),//
- "-batch",//
- "-md",
- rs.getString("md"),//
- "-extfile",
- "../" + f.getName(),//
-
- "-subj",
- Certificate.stringifyDN(subj),//
- "-config",
- "../selfsign.config"//
-
- };
+ String[] call;
+ synchronized (sdf) {
+ call = new String[] {
+ "openssl", "ca",//
+ "-in",
+ "../../" + csrname,//
+ "-cert",
+ "../" + ca + ".crt",//
+ "-keyfile",
+ "../" + ca + ".key",//
+ "-out",
+ "../../" + crt.getPath(),//
+ "-utf8",
+ "-startdate",
+ sdf.format(fromDate),//
+ "-enddate",
+ sdf.format(toDate),//
+ "-batch",//
+ "-md",
+ rs.getString("md"),//
+ "-extfile",
+ "../" + f.getName(),//
+
+ "-subj",
+ Certificate.stringifyDN(subj),//
+ "-config",
+ "../selfsign.config"//
+ };
+ }
+
if (ct == CSRType.SPKAC) {
call[2] = "-spkac";
}
+
Process p1 = Runtime.getRuntime().exec(call, null, new File("keys/unassured.ca"));
int waitFor = p1.waitFor();