]> WPIA git - cassiopeia.git/blobdiff - src/crypto/sslUtil.h
chg: rename package name and all references to it
[cassiopeia.git] / src / crypto / sslUtil.h
index 6ecb536cd5cac1ca479239da1411d042595d5925..569c20058eccd47dac2c2125e7e138bd6b774d96 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <memory>
 #include <string>
+#include <string.h>
 #include <vector>
 #include <cinttypes>
 #include <ctime>
@@ -13,6 +14,8 @@
 struct CAConfig {
     std::string path;
     std::string name;
+    std::string crlURL;
+    std::string crtURL;
 
     std::shared_ptr<X509> ca;
     std::shared_ptr<EVP_PKEY> caKey;
@@ -32,13 +35,20 @@ struct Profile {
     std::vector<std::shared_ptr<CAConfig>> ca;
     std::time_t maxValidity;
     std::shared_ptr<CAConfig> getCA() {
+        std::shared_ptr<CAConfig> min = nullptr;
         for( auto it = ca.rbegin(); it != ca.rend(); it++ ) {
-            if( X509_cmp_current_time( ( *it )->notBefore.get() ) < 0 ) {
-                return *it;
+            if( X509_cmp_current_time( ( *it )->notBefore.get() ) < 0) {
+                if(min != nullptr){
+                    if(strcmp(min->name.c_str(), (*it)->name.c_str()) < 0){
+                        min = *it;
+                    }
+                }else{
+                    min=*it;
+                }
             }
         }
 
-        return ca[0];
+        return min ? min : ca[0];
     }
 };