X-Git-Url: https://code.wpia.club/?p=cassiopeia.git;a=blobdiff_plain;f=src%2Fapps%2Fclient.cpp;fp=src%2Fapps%2Fclient.cpp;h=32ecc1f1f93a936dbdc0143f6cd4baac086af4ae;hp=63ff0cab5359aa1188c2f87c7c8d0dd48379f37c;hb=aafe58bf899c7c9711a6e319374ada4194408673;hpb=e17353862ab739c9de5bf1436b79e34cc72f5733 diff --git a/src/apps/client.cpp b/src/apps/client.cpp index 63ff0ca..32ecc1f 100644 --- a/src/apps/client.cpp +++ b/src/apps/client.cpp @@ -59,6 +59,33 @@ bool pathExists( const std::string& name ) { return stat( name.c_str(), &buffer ) == 0; } +void signOCSP( std::shared_ptr sign, std::string profileName, std::string req, std::string crtName ) { + auto cert = std::make_shared(); + cert->ocspCA = profileName; + cert->wishFrom = "now"; + cert->wishTo = "1y"; + cert->md = "sha512"; + + logger::note( "INFO: Message Digest: ", cert->md ); + + cert->csr_content = req; + cert->csr_type = "CSR"; + auto nAVA = std::make_shared(); + nAVA->name = "CN"; + nAVA->value = "OCSP Responder"; + cert->AVAs.push_back( nAVA ); + + std::shared_ptr res = sign->sign( cert ); + + if( !res ) { + logger::error( "OCSP Cert signing failed." ); + return; + } + + writeFile( crtName, res->certificate ); + logger::notef( "Cert log: %s", res->log ); +} + void checkOCSP( std::shared_ptr sign ) { std::unique_ptr> dp( opendir( "ca" ), []( DIR * d ) { closedir( d ); @@ -100,38 +127,7 @@ void checkOCSP( std::shared_ptr sign ) { continue; } - auto cert = std::make_shared(); - cert->ocspCA = profileName; - cert->wishFrom = "now"; - cert->wishTo = "1y"; - cert->md = "sha512"; - - logger::note( "INFO: Message Digest: ", cert->md ); - - for( auto& SAN : cert->SANs ) { - logger::notef( "INFO: SAN %s: %s", SAN->type, SAN->content ); - } - - for( auto& AVA : cert->AVAs ) { - logger::notef( "INFO: AVA %s: %s", AVA->name, AVA->value ); - } - - cert->csr_content = req; - cert->csr_type = "CSR"; - auto nAVA = std::make_shared(); - nAVA->name = "CN"; - nAVA->value = "OCSP Responder"; - cert->AVAs.push_back( nAVA ); - - std::shared_ptr res = sign->sign( cert ); - - if( !res ) { - logger::error( "OCSP Cert signing failed." ); - continue; - } - - writeFile( crtName, res->certificate ); - logger::notef( "Cert log: %s", res->log ); + signOCSP( sign, profileName, req, crtName ); } }