X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Fcrypto%2FsslUtil.h;h=2ecba42b9874686014d7c72ac77919de321a1b63;hb=6121035a7d8ea738bc89c2de8e6602fb1099b0e2;hp=4a451b3a1903aae6d251c1579f5e71efbe89c79a;hpb=1867e1ad94f4549869b23a68851caf34cfbf8e8b;p=cassiopeia.git diff --git a/src/crypto/sslUtil.h b/src/crypto/sslUtil.h index 4a451b3..2ecba42 100644 --- a/src/crypto/sslUtil.h +++ b/src/crypto/sslUtil.h @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -34,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]; } };