X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Fcrypto%2FsslUtil.h;h=1327a17bd47367dd0113ce8dec984e1ca93ccb27;hb=87325777087f80af2065a09977ae6abf39bc50d1;hp=7a6850451f81566477930f14791a7223b7e34686;hpb=9e866a1a2facc8cb1565cd660c6b6d482f18ecb1;p=cassiopeia.git diff --git a/src/crypto/sslUtil.h b/src/crypto/sslUtil.h index 7a68504..1327a17 100644 --- a/src/crypto/sslUtil.h +++ b/src/crypto/sslUtil.h @@ -1,8 +1,14 @@ #pragma once -#include + #include #include +#include #include +#include + +#include + +#include "db/database.h" class CAConfig { public: @@ -11,24 +17,36 @@ public: std::shared_ptr ca; std::shared_ptr caKey; - CAConfig( std::string name ); - + std::shared_ptr notBefore; + CAConfig( const std::string& name ); + bool crlNeedsResign(); }; - struct Profile { uint16_t id; std::string eku; std::string ku; - std::shared_ptr ca; + std::vector> ca; + std::time_t maxValidity; + std::shared_ptr getCA() { + for( auto it = ca.rbegin(); it != ca.rend(); it++ ) { + if( X509_cmp_current_time( ( *it )->notBefore.get() ) < 0 ) { + return *it; + } + } + + return ca[0]; + } }; extern std::shared_ptr ssl_lib_ref; -std::shared_ptr loadX509FromFile( std::string filename ); -std::shared_ptr loadPkeyFromFile( std::string filename ); +std::shared_ptr loadX509FromFile( const std::string& filename ); +std::shared_ptr loadPkeyFromFile( const std::string& filename ); std::shared_ptr generateSSLContext( bool server ); -std::shared_ptr openSerial( const std::string name ); +std::shared_ptr openSerial( const std::string& name ); +std::string timeToString( std::shared_ptr time ); +void extractTimes( std::shared_ptr source, std::shared_ptr cert );