mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-23 08:31:43 +02:00
#3269: Poco::Net::Context initialization with empty certificateFile
This commit is contained in:
@@ -137,6 +137,7 @@ public:
|
|||||||
|
|
||||||
std::string certificateFile;
|
std::string certificateFile;
|
||||||
/// Path to the certificate file (in PEM format).
|
/// Path to the certificate file (in PEM format).
|
||||||
|
///
|
||||||
/// If the private key and the certificate are stored in the same file, this
|
/// If the private key and the certificate are stored in the same file, this
|
||||||
/// can be empty if privateKeyFile is given.
|
/// can be empty if privateKeyFile is given.
|
||||||
|
|
||||||
|
@@ -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)
|
if (errCode != 1)
|
||||||
{
|
{
|
||||||
std::string errMsg = Utility::getLastError();
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user