upd: make simple Signer more intelligent in choosing CA certificate
authorFelix Dörre <felix@dogcraft.de>
Thu, 25 Aug 2016 14:35:06 +0000 (16:35 +0200)
committerFelix Dörre <felix@dogcraft.de>
Thu, 25 Aug 2016 15:11:31 +0000 (17:11 +0200)
Change-Id: I24420cc7a5cd78b460e26dfc58203b4bb0fc0adb

util-testing/org/cacert/gigi/util/SimpleSigner.java

index 6b498988628d5b125063a232f857074e7a910738..9a2fb1074f612bd62ce4f5f850d31ec644b87fd8 100644 (file)
@@ -28,6 +28,7 @@ import java.text.SimpleDateFormat;
 import java.util.Base64;
 import java.util.Calendar;
 import java.util.Date;
+import java.util.GregorianCalendar;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
@@ -327,7 +328,8 @@ public class SimpleSigner {
                     PKCS10 p10 = new PKCS10(PEM.decode("(NEW )?CERTIFICATE REQUEST", new String(data, "UTF-8")));
                     pk = p10.getSubjectPublicKeyInfo();
                 }
-                String ca = caP.getProperty("ca") + "_2015_1";
+                Calendar cal = GregorianCalendar.getInstance();
+                String ca = caP.getProperty("ca") + "_" + cal.get(Calendar.YEAR) + (cal.get(Calendar.MONTH) >= 6 ? "_2" : "_1");
                 File parent = new File("signer/ca");
                 File[] caFiles = parent.listFiles();
                 if (null == caFiles) {