#3269: Poco::Net::Context initialization with empty certificateFile

This commit is contained in:
Günter Obiltschnig
2021-06-15 14:05:56 +02:00
parent e01fede825
commit 907e240ff2
2 changed files with 6 additions and 3 deletions

View File

@@ -155,13 +155,15 @@ void Context::init(const Params& params)
}
}
if (!params.certificateFile.empty())
std::string certificateFile = params.certificateFile;
if (certificateFile.empty()) certificateFile = params.privateKeyFile;
if (!certificateFile.empty())
{
errCode = SSL_CTX_use_certificate_chain_file(_pSSLContext, Poco::Path::transcode(params.certificateFile).c_str());
errCode = SSL_CTX_use_certificate_chain_file(_pSSLContext, Poco::Path::transcode(certificateFile).c_str());
if (errCode != 1)
{
std::string errMsg = Utility::getLastError();
throw SSLContextException(std::string("Error loading certificate from file ") + params.certificateFile, errMsg);
throw SSLContextException(std::string("Error loading certificate from file ") + certificateFile, errMsg);
}
}