read_id = std::string( row[0], row[0] + l[0] );
}
- std::string q = "UPDATE certs SET crt_name='" + this->escape_string( res->crt_name ) + "', serial='" + this->escape_string( res->serial ) + "', caId = '" + this->escape_string( read_id ) + "', created=NOW() WHERE id='" + this->escape_string( job->target ) + "' LIMIT 1";
-
+ std::string q = "UPDATE certs SET crt_name='" + this->escape_string( res->crt_name ) + "', serial='" + this->escape_string( res->serial ) + "', caId = '" + this->escape_string( read_id ) + "', created='" + this->escape_string( res->before ) + "', expire='" + this->escape_string( res->after ) + "' WHERE id='" + this->escape_string( job->target ) + "' LIMIT 1";
// TODO write more thingies back
if( query( q ).first ) {
throw "Error while writing back";
}
}
+
+std::pair<std::string, std::string> MySQLJobProvider::getRevocationInfo( std::shared_ptr<Job> job ) {
+ std::string q = "SELECT certs.serial, cacerts.keyname FROM certs INNER JOIN cacerts ON certs.caId = cacerts.id WHERE certs.id = '" + this->escape_string( job->target ) + "' ";
+ int err = 0;
+ std::shared_ptr<MYSQL_RES> resu;
+ std::tie( err, resu ) = query( q );
+
+ if( err ) {
+ throw "Error while looking ca cert id";
+ }
+
+ MYSQL_ROW row = mysql_fetch_row( resu.get() );
+ unsigned long* l = mysql_fetch_lengths( resu.get() );
+
+ if( !row || !l ) {
+ throw "Error while inserting new ca cert";
+ }
+
+ return std::pair<std::string, std::string>( std::string( row[0], row[0] + l[0] ), std::string( row[1], row[1] + l[1] ) );
+}
+
+void MySQLJobProvider::writeBackRevocation( std::shared_ptr<Job> job, std::string date ) {
+ if( query( "UPDATE certs SET revoked = '" + this->escape_string( date ) + "' WHERE id = '" + this->escape_string( job->target ) + "'" ).first ) {
+ throw "Error while writing back revocation";
+ }
+}