- signlog << "FINE: Signed" << std::endl;
- std::shared_ptr<SignedCertificate> output = c.sign( ca->caKey, cert->md );
- signlog << "FINE: all went well" << std::endl;
- signlog << "FINE: crt went to: " << writeBackFile( num, output->certificate, ca->path ) << std::endl;
- output->ca_name = ca->name;
- output->log = signlog.str();
- return output;
+ signlog << "FINE: Setting extensions successful." << std::endl;
+
+ signlog << "INFO: Generating next Serial Number ..." << std::endl;
+ std::shared_ptr<BIGNUM> ser;
+ std::string num;
+ std::tie( ser, num ) = nextSerial( prof, ca );
+ c.setSerialNumber( ser.get() );
+ signlog << "FINE: Certificate Serial Number set to:" << num << std::endl;
+
+ {
+ signlog << "INFO: Trying to sign Certificate:" << std::endl;
+ std::shared_ptr<SignedCertificate> output = c.sign( ca->caKey, cert->md );
+ signlog << "INFO: Writing certificate to local file." << std::endl;
+ std::string fn = writeBackFile( num, output->certificate, ca->path );
+
+ if( fn.empty() ) {
+ signlog << "ERROR: failed to get filename for storage of signed certificate." << std::endl;
+ throw "Storage location could not be determined";
+ }
+ signlog << "FINE: Certificate signed successfully." << std::endl;
+ signlog << "FINE: - Certificate written to: " << fn << std::endl;
+
+ output->ca_name = ca->name;
+ output->log = signlog.str();
+ return output;
+ }
+