From ce394ae18730bf1b9dd7c96f7669a68395e629c8 Mon Sep 17 00:00:00 2001 From: Alex Rousskov Date: Mon, 20 Feb 2012 14:40:59 -0700 Subject: [PATCH] Fixed Ssl::CrtdMessage::parseRequest(properties, error) profile to allow this method to return error texts using its second argument. Polished error formatting. --- src/ssl/crtd_message.cc | 9 +++++---- src/ssl/crtd_message.h | 2 +- src/ssl/ssl_crtd.cc | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ssl/crtd_message.cc b/src/ssl/crtd_message.cc index ddcda17560..3ba5118cb1 100644 --- a/src/ssl/crtd_message.cc +++ b/src/ssl/crtd_message.cc @@ -174,14 +174,15 @@ void Ssl::CrtdMessage::composeBody(CrtdMessage::BodyParams const & map, std::str body += '\n' + other_part; } -bool Ssl::CrtdMessage::parseRequest(Ssl::CertificateProperties &certProperties, std::string error) + +bool Ssl::CrtdMessage::parseRequest(Ssl::CertificateProperties &certProperties, std::string &error) { Ssl::CrtdMessage::BodyParams map; std::string certs_part; parseBody(map, certs_part); Ssl::CrtdMessage::BodyParams::iterator i = map.find(Ssl::CrtdMessage::param_host); if (i == map.end()) { - error = "Parse request: Cannot find \"host\" parameter in request message"; + error = "Cannot find \"host\" parameter in request message"; return false; } certProperties.commonName = i->second; @@ -205,7 +206,7 @@ bool Ssl::CrtdMessage::parseRequest(Ssl::CertificateProperties &certProperties, i = map.find(Ssl::CrtdMessage::param_Sign); if (i != map.end()) { if ((certProperties.signAlgorithm = Ssl::certSignAlgorithmId(i->second.c_str())) == Ssl::algSignEnd) { - error = "Parse request: Wrong signing algoritm: " + i->second; + error = "Wrong signing algoritm: " + i->second; return false; } } @@ -214,7 +215,7 @@ bool Ssl::CrtdMessage::parseRequest(Ssl::CertificateProperties &certProperties, if (certProperties.signAlgorithm != Ssl::algSignSelf && !Ssl::readCertAndPrivateKeyFromMemory(certProperties.signWithX509, certProperties.signWithPkey, certs_part.c_str())) { - error = "Parse request: Broken signing certificate!"; + error = "Broken signing certificate!"; return false; } diff --git a/src/ssl/crtd_message.h b/src/ssl/crtd_message.h index 6149cf7227..af6e084fe8 100644 --- a/src/ssl/crtd_message.h +++ b/src/ssl/crtd_message.h @@ -64,7 +64,7 @@ public: */ void composeBody(BodyParams const & map, std::string const & other_part); - bool parseRequest(Ssl::CertificateProperties &, std::string error); + bool parseRequest(Ssl::CertificateProperties &, std::string &error); void composeRequest(Ssl::CertificateProperties const &); /// String code for "new_certificate" messages diff --git a/src/ssl/ssl_crtd.cc b/src/ssl/ssl_crtd.cc index 0855b70467..c2bec535e2 100644 --- a/src/ssl/ssl_crtd.cc +++ b/src/ssl/ssl_crtd.cc @@ -214,7 +214,7 @@ static bool proccessNewRequest(Ssl::CrtdMessage & request_message, std::string c Ssl::CertificateProperties certProperties; std::string error; if (!request_message.parseRequest(certProperties, error)) - throw std::runtime_error("Error while parsing the crtd request" + error); + throw std::runtime_error("Error while parsing the crtd request: " + error); Ssl::CertificateDb db(db_path, max_db_size, fs_block_size); Ssl::X509_Pointer cert; -- 2.47.2