X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Fcrypto%2FsslUtil.h;h=2ecba42b9874686014d7c72ac77919de321a1b63;hb=6121035a7d8ea738bc89c2de8e6602fb1099b0e2;hp=6ecb536cd5cac1ca479239da1411d042595d5925;hpb=3c27aae8d1bfbf441c25b273d328d0859022ed60;p=cassiopeia.git diff --git a/src/crypto/sslUtil.h b/src/crypto/sslUtil.h index 6ecb536..2ecba42 100644 --- a/src/crypto/sslUtil.h +++ b/src/crypto/sslUtil.h @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -13,6 +14,8 @@ struct CAConfig { std::string path; std::string name; + std::string crlURL; + std::string crtURL; std::shared_ptr ca; std::shared_ptr caKey; @@ -32,13 +35,21 @@ struct Profile { std::vector> ca; std::time_t maxValidity; std::shared_ptr getCA() { + std::shared_ptr min = nullptr; + for( auto it = ca.rbegin(); it != ca.rend(); it++ ) { if( X509_cmp_current_time( ( *it )->notBefore.get() ) < 0 ) { - return *it; + 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]; } };