mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-12 18:20:26 +01:00
#3269: Poco::Net::Context initialization with empty certificateFile
This commit is contained in:
parent
e01fede825
commit
907e240ff2
@ -137,6 +137,7 @@ public:
|
||||
|
||||
std::string certificateFile;
|
||||
/// Path to the certificate file (in PEM format).
|
||||
///
|
||||
/// If the private key and the certificate are stored in the same file, this
|
||||
/// 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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user