]> WPIA git - cassiopeia.git/blobdiff - src/crypto/simpleOpensslSigner.cpp
fmt: Whitespace
[cassiopeia.git] / src / crypto / simpleOpensslSigner.cpp
index 22687be3c518579a3b9fbd1531726bb51acefc6c..b6005b7483c112e85ed108f0939331a582c94ae8 100644 (file)
@@ -109,12 +109,6 @@ std::shared_ptr<SignedCertificate> SimpleOpensslSigner::sign( std::shared_ptr<TB
 
     // Construct the Certificate
     X509Cert c = X509Cert();
-    std::shared_ptr<X509> retsh = std::shared_ptr<X509>( X509_new(), X509_free );
-    X509* ret = retsh.get();
-
-    if( !ret ) {
-        throw "Creating X509 failed.";
-    }
 
     X509_NAME* subjectP = X509_NAME_new();
 
@@ -184,7 +178,7 @@ std::shared_ptr<SignedCertificate> SimpleOpensslSigner::sign( std::shared_ptr<TB
         to = from + /*2 Years */ 2 * 365 * 24 * 60 * 60;
     }
 
-    time_t limit = /*2 Years (max possible) */ 2 * 366 * 24 * 60 * 60;
+    time_t limit = prof.maxValidity;
 
     if( to - from > limit || to - from < 0 ) {
         to = from + limit;
@@ -196,7 +190,14 @@ std::shared_ptr<SignedCertificate> SimpleOpensslSigner::sign( std::shared_ptr<TB
     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;
+    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: crt went to: " << fn << std::endl;
     output->ca_name = ca->name;
     output->log = signlog.str();
     return output;