X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Fcrypto%2FCRL.cpp;h=41fbe8b6472464af1dbcfab4ed5aec66b7cf44bd;hb=e0713d1539887566e0ea7d85942c305ec727c9dd;hp=08b49cdc3b0607fd910983a4c7e2ef2d42f96e6e;hpb=90a79f28e095c7e368971ee5408ba8a10e0043c9;p=cassiopeia.git diff --git a/src/crypto/CRL.cpp b/src/crypto/CRL.cpp index 08b49cd..41fbe8b 100644 --- a/src/crypto/CRL.cpp +++ b/src/crypto/CRL.cpp @@ -2,9 +2,10 @@ #include #include +#include CRL::CRL( std::string path ) { - std::shared_ptr bio( BIO_new_file( path.c_str(), "r" ), free ); + std::shared_ptr bio( BIO_new_file( path.c_str(), "r" ), BIO_free ); crl = std::shared_ptr( PEM_read_bio_X509_CRL( bio.get(), 0, NULL, 0 ), X509_CRL_free ); if( !crl ) { @@ -17,21 +18,21 @@ std::string CRL::revoke( std::string serial, std::string time ) { logger::note("parsing serial"); if( ! BN_hex2bn( &serBN, serial.c_str() ) ) { - throw "hex2bn malloc fail"; + throw std::runtime_error("hex2bn malloc fail"); } std::shared_ptr serBNP( serBN, BN_free ); std::shared_ptr ser( BN_to_ASN1_INTEGER( serBN, NULL ), ASN1_INTEGER_free ); if( !ser ) { - throw "BN Malloc fail"; + throw std::runtime_error("BN Malloc fail"); } logger::note("building current time"); std::shared_ptr tmptm( ASN1_TIME_new(), ASN1_TIME_free ); if( !tmptm ) { - throw "ASN1-Time Malloc fail"; + throw std::runtime_error("ASN1-Time Malloc fail"); } X509_gmtime_adj( tmptm.get(), 0 ); @@ -63,21 +64,21 @@ void CRL::sign( std::shared_ptr ca ) { std::shared_ptr tmptm( ASN1_TIME_new(), ASN1_TIME_free ); if( !tmptm ) { - throw "ASN1-Time Malloc fail"; + throw std::runtime_error("ASN1-Time Malloc fail"); } X509_gmtime_adj( tmptm.get(), 0 ); logger::note("setting issuer"); if( !X509_CRL_set_issuer_name( crl.get(), X509_get_subject_name( ca->ca.get() ) ) ) { - throw "Setting issuer failed"; + throw std::runtime_error("Setting issuer failed"); } logger::note("setting update"); X509_CRL_set_lastUpdate( crl.get(), tmptm.get() ); if( !X509_time_adj_ex( tmptm.get(), 1, 10, NULL ) ) { - throw "Updating time failed"; + throw std::runtime_error("Updating time failed"); } logger::note("setting next update");