From 6830d598f51f17ca4d96bff173a584241f43074b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Felix=20D=C3=B6rre?= Date: Fri, 26 May 2017 11:34:30 +0000 Subject: [PATCH] fix: mark failed OCSP signature attempts to prevent re-signing Change-Id: I62cb3d5906722a00442725c0a8f7dd66027f6606 --- src/apps/client.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/apps/client.cpp b/src/apps/client.cpp index 32ecc1f..aa0e06c 100644 --- a/src/apps/client.cpp +++ b/src/apps/client.cpp @@ -59,7 +59,7 @@ 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 ) { +void signOCSP( std::shared_ptr sign, std::string profileName, std::string req, std::string crtName, std::string failName ) { auto cert = std::make_shared(); cert->ocspCA = profileName; cert->wishFrom = "now"; @@ -78,6 +78,7 @@ void signOCSP( std::shared_ptr sign, std::string profileName, std::strin std::shared_ptr res = sign->sign( cert ); if( !res ) { + writeFile( failName, "failed" ); logger::error( "OCSP Cert signing failed." ); return; } @@ -118,6 +119,12 @@ void checkOCSP( std::shared_ptr sign ) { continue; } + std::string failName = "ca/" + profileName + "/ocsp.fail"; + + if( pathExists( failName ) ) { + continue; + } + logger::notef( "Discovered OCSP CSR that needs action: %s", csr ); std::string req = readFile( csr ); std::shared_ptr parsed = X509Req::parseCSR( req ); @@ -127,7 +134,7 @@ void checkOCSP( std::shared_ptr sign ) { continue; } - signOCSP( sign, profileName, req, crtName ); + signOCSP( sign, profileName, req, crtName, failName ); } } -- 2.39.2