+void signOCSP( std::shared_ptr<Signer> sign, std::string profileName, std::string req, std::string crtName, std::string failName ) {
+ auto cert = std::make_shared<TBSCertificate>();
+ cert->ocspCA = profileName;
+ cert->wishFrom = "now";
+ cert->wishTo = "1y";
+ cert->md = "sha512";
+
+ logger::note( "INFO: Message Digest: ", cert->md );
+
+ cert->csr_content = req;
+ cert->csr_type = "CSR";
+ auto nAVA = std::make_shared<AVA>();
+ nAVA->name = "CN";
+ nAVA->value = "OCSP Responder";
+ cert->AVAs.push_back( nAVA );
+
+ std::shared_ptr<SignedCertificate> res = sign->sign( cert );
+
+ if( !res ) {
+ writeFile( failName, "failed" );
+ logger::error( "OCSP Cert signing failed." );
+ return;
+ }
+
+ writeFile( crtName, res->certificate );
+ logger::notef( "Cert log: %s", res->log );
+}
+
+void checkOCSP( std::shared_ptr<Signer> sign ) {
+ std::unique_ptr<DIR, std::function<void( DIR * )>> dp( opendir( "ca" ), []( DIR * d ) {
+ closedir( d );
+ } );
+
+ // When opendir fails and returns 0 the unique_ptr will be considered unintialized and will not call closedir.
+ // Even if closedir would be called, according to POSIX it MAY handle nullptr properly (for glibc it does).
+ if( !dp ) {
+ logger::error( "CA directory not found" );
+ return;
+ }