Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-32053 Avoid crash when secure roxie is configured with no cert #18762

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/thorhelper/thorsoapcall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ class CWSCHelper : implements IWSCHelper, public CInterface
{
if (clientCert != NULL)
{
Owned<IPropertyTree> config = createSecureSocketConfig(clientCert->certificate, clientCert->privateKey, clientCert->passphrase);
Owned<IPropertyTree> config = createSecureSocketConfig(clientCert->certificate, clientCert->privateKey, clientCert->passphrase, true);
ownedSC.setown(createSecureSocketContextEx2(config, ClientSocket));
}
else if (clientCertIssuer.length())
Expand Down
4 changes: 2 additions & 2 deletions esp/services/ws_ecl/ws_ecl_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ void initBareMetalRoxieTargets(MapStringToMyClass<ISmartSocketFactory> &connMap,
includeTargetInURL = pc->getPropBool("@includeTargetInURL", true);
dnsInterval = (unsigned) pc->getPropInt("@dnsInterval", -1);
if (pc->getPropBool("@tls", false))
tlsConfig.setown(createSecureSocketConfig(nullptr, nullptr, nullptr));
tlsConfig.setown(createSecureSocketConfig(nullptr, nullptr, nullptr, true));
}
}
StringBuffer list;
Expand Down Expand Up @@ -299,7 +299,7 @@ void initBareMetalRoxieTargets(MapStringToMyClass<ISmartSocketFactory> &connMap,
farmerPort = port;
const char *protocol = farmer.queryProp("@protocol");
if (protocol && streq(protocol, "ssl"))
tlsConfig.setown(createSecureSocketConfig(farmer.queryProp("@certificateFileName"), farmer.queryProp("@privateKeyFileName"), nullptr));
tlsConfig.setown(createSecureSocketConfig(farmer.queryProp("@certificateFileName"), farmer.queryProp("@privateKeyFileName"), nullptr, true));
break; //use the first one without port==0
}
Owned<IPropertyTreeIterator> servers = roxieCluster->getElements("RoxieServerProcess");
Expand Down
2 changes: 1 addition & 1 deletion esp/smc/SMCLib/TpWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2144,7 +2144,7 @@ extern TPWRAPPER_API void initBareMetalRoxieTargets(MapStringToMyClass<ISmartSoc
if (!isEmptyString(protocol) && strieq(protocol, "ssl"))
{
port.set(farmPort);
tlsConfig.setown(createSecureSocketConfig(farm.queryProp("@certificateFileName"), farm.queryProp("@privateKeyFileName"), nullptr));
tlsConfig.setown(createSecureSocketConfig(farm.queryProp("@certificateFileName"), farm.queryProp("@privateKeyFileName"), nullptr, true));
break;
}
else if (isEmptyString(port.str()))
Expand Down
2 changes: 1 addition & 1 deletion fs/dafsclient/rmtclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static class _securitySettingsClient
const IPropertyTree * getSecureConfig()
{
//Later: return a synced tree...
return createSecureSocketConfig(queryCertificate(), queryPrivateKey(), queryPassPhrase());
return createSecureSocketConfig(queryCertificate(), queryPrivateKey(), queryPassPhrase(), false);
}

protected:
Expand Down
2 changes: 1 addition & 1 deletion fs/dafsserver/dafsserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static class _securitySettingsServer
const IPropertyTree * getSecureConfig()
{
//Later: return a synced tree...
return createSecureSocketConfig(certificate, privateKey, passPhrase);
return createSecureSocketConfig(certificate, privateKey, passPhrase, false);
}

} securitySettings;
Expand Down
2 changes: 1 addition & 1 deletion roxie/ccd/ccdmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1622,7 +1622,7 @@ int CCD_API roxie_main(int argc, const char *argv[], const char * defaultYaml)
if (!checkFileExists(keyFileName.str()))
throw MakeStringException(ROXIE_FILE_ERROR, "Roxie SSL Farm Listener on port %d missing privateKeyFile (%s)", port, keyFileName.str());

Owned<IPropertyTree> staticConfig = createSecureSocketConfig(certFileName, keyFileName, passPhraseStr);
Owned<IPropertyTree> staticConfig = createSecureSocketConfig(certFileName, keyFileName, passPhraseStr, false);
tlsConfig.setown(createSyncedPropertyTree(staticConfig));
}
else
Expand Down
2 changes: 1 addition & 1 deletion roxie/roxiepipe/roxiepipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ int main(int argc, char *argv[])
{
#ifdef _USE_OPENSSL
if (useSSL)
smartSocketFactory = createSecureSmartSocketFactory(hosts.str(), createSecureSocketConfig(nullptr, nullptr, nullptr), retryMode);
smartSocketFactory = createSecureSmartSocketFactory(hosts.str(), createSecureSocketConfig(nullptr, nullptr, nullptr, true), retryMode);
else
#endif
smartSocketFactory = createSmartSocketFactory(hosts.str(), retryMode);
Expand Down
9 changes: 6 additions & 3 deletions system/security/securesocket/securesocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2051,10 +2051,13 @@ SECURESOCKET_API ISecureSocketContext* createSecureSocketContextSecretSrv(const
return createSecureSocketContextSynced(info, ServerSocket);
}

IPropertyTree * createSecureSocketConfig(const char* certFileOrBuf, const char* privKeyFileOrBuf, const char* passphrase)
IPropertyTree * createSecureSocketConfig(const char* certFileOrBuf, const char* privKeyFileOrBuf, const char* passphrase, bool createIfAllNull)
{
if (!certFileOrBuf && !privKeyFileOrBuf && !passphrase)
return nullptr;
if (!createIfAllNull)
{
if (!certFileOrBuf && !privKeyFileOrBuf && !passphrase)
return nullptr;
}

Owned<IPropertyTree> config = createPTree("ssl");
if (certFileOrBuf)
Expand Down
2 changes: 1 addition & 1 deletion system/security/securesocket/securesocket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ SECURESOCKET_API ISecureSocketContext* createSecureSocketContextSecretSrv(const
SECURESOCKET_API ISecureSocketContext* createSecureSocketContextSSF(ISmartSocketFactory* ssf);

//Helper function to aid migration to the functions above. This should eventually be removed.
SECURESOCKET_API IPropertyTree * createSecureSocketConfig(const char* certFileOrBuf, const char* privKeyFileOrBuf, const char* passphrase);
SECURESOCKET_API IPropertyTree * createSecureSocketConfig(const char* certFileOrBuf, const char* privKeyFileOrBuf, const char* passphrase, bool createIfAllNull);

//Legacy factory methods - should be phased out.
SECURESOCKET_API ISecureSocketContext* createSecureSocketContext(SecureSocketType);
Expand Down
Loading