- first = false;
- cfg.print(san.getString("type"));
- cfg.print(":");
- cfg.print(san.getString("contents"));
- }
- cfg.println();
- cfg.println("keyUsage=" + keyUsage);
- cfg.println("extendedKeyUsage=" + ekeyUsage);
- cfg.close();
-
- String[] call = new String[] {
- "openssl", "ca",//
- "-in",
- "../../" + csrname,//
- "-cert",
- "../unassured.crt",//
- "-keyfile",
- "../unassured.key",//
- "-out",
- "../../" + crt.getPath(),//
- "-utf8",
- "-days",
- "356",//
- "-batch",//
- "-md",
- rs.getString("md"),//
- "-extfile",
- "../" + f.getName(),//
-
- "-subj",
- rs.getString("subject"),//
- "-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();
- f.delete();
- if (waitFor == 0) {
- try (InputStream is = new FileInputStream(crt)) {
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- X509Certificate crtp = (X509Certificate) cf.generateCertificate(is);
- BigInteger serial = crtp.getSerialNumber();
- updateMail.setString(1, crt.getPath());
- updateMail.setString(2, serial.toString(16));
- updateMail.setInt(3, id);
- updateMail.execute();
-
- finishJob.setInt(1, rs.getInt("jobid"));
- finishJob.execute();
- System.out.println("signed: " + id);
- continue;
- } catch (GeneralSecurityException e) {
- e.printStackTrace();
+ if (length.endsWith("m") || length.endsWith("y")) {
+ String num = length.substring(0, length.length() - 1);
+ int inter = Integer.parseInt(num);
+ Calendar c = Calendar.getInstance();
+ c.setTimeZone(TimeZone.getTimeZone("UTC"));
+ c.setTime(fromDate);
+ if (length.endsWith("m")) {
+ c.add(Calendar.MONTH, inter);
+ } else {
+ c.add(Calendar.YEAR, inter);
+ }
+ toDate = c.getTime();
+ } else {
+ toDate = CertificateValiditySelector.getDateFormat().parse(length);