}
#if USE_SSL_CRTD
+ try {
debugs(33, 5, HERE << "Generating SSL certificate for " << certProperties.commonName << " using ssl_crtd.");
Ssl::CrtdMessage request_message;
request_message.setCode(Ssl::CrtdMessage::code_new_certificate);
debugs(33, 5, HERE << "SSL crtd request: " << request_message.compose().c_str());
Ssl::Helper::GetInstance()->sslSubmit(request_message, sslCrtdHandleReplyWrapper, this);
return;
-#else
+ }
+ catch (const std::exception &e) {
+ debugs(33, DBG_IMPORTANT, "ERROR: Failed to compose ssl_crtd " <<
+ "request for " << certProperties.commonName <<
+ " certificate: " << e.what() << "; will now block to " <<
+ "generate that certificate.");
+ // fall through to do blocking in-process generation.
+ }
+#endif // USE_SSL_CRTD
+
debugs(33, 5, HERE << "Generating SSL certificate for " << certProperties.commonName);
dynCtx = Ssl::generateSslContext(certProperties);
getSslContextDone(dynCtx, true);
return;
-#endif //USE_SSL_CRTD
}
getSslContextDone(NULL);
}
#if HAVE_CSTRING
#include <cstring>
#endif
+#if HAVE_STDEXCEPT
+#include <stdexcept>
+#endif
Ssl::CrtdMessage::CrtdMessage()
: body_size(0), state(BEFORE_CODE)
body += "\n" + Ssl::CrtdMessage::param_Sign + "=" + certSignAlgorithm(certProperties.signAlgorithm);
std::string certsPart;
- bool ret = Ssl::writeCertAndPrivateKeyToMemory(certProperties.signWithX509, certProperties.signWithPkey, certsPart);
- assert(ret);
+ if (!Ssl::writeCertAndPrivateKeyToMemory(certProperties.signWithX509, certProperties.signWithPkey, certsPart) || true)
+ throw std::runtime_error("Ssl::writeCertAndPrivateKeyToMemory()");
if (certProperties.mimicCert.get()) {
- ret = Ssl::appendCertToMemory(certProperties.mimicCert, certsPart);
- assert(ret);
+ if (!Ssl::appendCertToMemory(certProperties.mimicCert, certsPart))
+ throw std::runtime_error("Ssl::appendCertToMemory()");
}
body += "\n" + certsPart;
}
void composeBody(BodyParams const & map, std::string const & other_part);
bool parseRequest(Ssl::CertificateProperties &, std::string &error);
- void composeRequest(Ssl::CertificateProperties const &);
+ void composeRequest(Ssl::CertificateProperties const &); // throws
/// String code for "new_certificate" messages
static const std::string code_new_certificate;