]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/dbObjects/CACertificate.java
Merge "Fix error message"
[gigi.git] / src / org / cacert / gigi / dbObjects / CACertificate.java
index 41401b6ddab883b84e10180f766bf1492882d212..bc96a5a5f3db89b0188e2d9075ac068c2b77fa2d 100644 (file)
@@ -89,7 +89,11 @@ public class CACertificate implements IdCachable {
         CertificateFactory xf = CertificateFactory.getInstance("X509");
         HashMap<X500Principal, X509Certificate> map = new HashMap<>();
         HashMap<X500Principal, String> names = new HashMap<>();
-        for (File f : scandir.listFiles()) {
+        File[] scandirfiles = scandir.listFiles();
+        if (null == scandirfiles) {
+            scandirfiles = new File[0];
+        }
+        for (File f : scandirfiles) {
             X509Certificate cert = (X509Certificate) xf.generateCertificate(new FileInputStream(f));
             X500Principal princip = cert.getSubjectX500Principal();
             map.put(princip, cert);
@@ -138,7 +142,7 @@ public class CACertificate implements IdCachable {
                             id = q2.lastInsertId();
                         }
                         if (self) {
-                            try (GigiPreparedStatement q3 = new GigiPreparedStatement("UPDATE `cacerts` SET `parentRoot`=?, `id`=?")) {
+                            try (GigiPreparedStatement q3 = new GigiPreparedStatement("UPDATE `cacerts` SET `parentRoot`=? WHERE `id`=?")) {
                                 q3.setInt(1, id);
                                 q3.setInt(2, id);
                                 q3.execute();