X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcrypto%2FsslUtil.cpp;h=687387c1573c7d9c615fdcfcff78cb3ab838b9d6;hb=90a79f28e095c7e368971ee5408ba8a10e0043c9;hp=81db0ba4f1d55db3dcdfd713b8c6cce12917d751;hpb=709700dfbbeb5bf8aee1f5a1966f0192d783ae03;p=cassiopeia.git diff --git a/src/crypto/sslUtil.cpp b/src/crypto/sslUtil.cpp index 81db0ba..687387c 100644 --- a/src/crypto/sslUtil.cpp +++ b/src/crypto/sslUtil.cpp @@ -188,17 +188,31 @@ std::shared_ptr openSerial( const std::string& name ) { } ); } +extern std::string crlPrefix; +extern std::string crtPrefix; + CAConfig::CAConfig( const std::string& name ) : path( "ca/" + name ), name( name ) { ca = loadX509FromFile( path + "/ca.crt" ); caKey = loadPkeyFromFile( path + "/ca.key" ); ASN1_TIME* tm = X509_get_notBefore( ca ); notBefore = std::shared_ptr( tm, ASN1_TIME_free ); + std::size_t pos = name.find("_"); + if (pos == std::string::npos) { + throw new std::invalid_argument("ca name: " + name + " is malformed."); + } + std::size_t pos2 = name.find("_", pos + 1); + if (pos2 == std::string::npos) { + throw new std::invalid_argument("ca name: " + name + " is malformed."); + } + crlURL = crlPrefix + "/g2/" + name.substr(pos+1, pos2-pos - 1) + "/" + name.substr(0,pos) + "-" + name.substr(pos2+1) + ".crl"; + crtURL = crtPrefix + "/g2/" + name.substr(pos+1, pos2-pos - 1) + "/" + name.substr(0,pos) + "-" + name.substr(pos2+1) + ".crt"; } std::string timeToString( std::shared_ptr time ) { std::shared_ptr gtime( ASN1_TIME_to_generalizedtime( time.get(), 0 ) ); std::string strdate( ( char* ) ASN1_STRING_data( gtime.get() ), ASN1_STRING_length( gtime.get() ) ); + logger::notef("openssl formatted me a date: %s", strdate); if( strdate[strdate.size() - 1] != 'Z' ) { throw "Got invalid date?"; }