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-30755 Allow ESP server TLS config to be based on an issuer name #18045

Closed
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
45 changes: 24 additions & 21 deletions esp/bindings/http/platform/httpprot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,32 +216,35 @@ CSecureHttpProtocol::CSecureHttpProtocol(IPropertyTree* cfg)
{
m_config.setown(cfg);

//ensure keys are specified. Passphrase is optional
StringBuffer sb;
cfg->getProp("certificate", sb);
if(sb.length() == 0)
{
throw MakeStringException(-1, "certificate file not specified in config file");
}
IEspPlugin *pplg = loadPlugin(SSLIB);
if (!pplg)
throw MakeStringException(-1, "dll/shared-object %s can't be loaded", SSLIB);

cfg->getProp("privatekey", sb.clear());
if(sb.length() == 0)
const char *issuer = cfg->queryProp("issuer");
if (!isEmptyString(issuer))
{
throw MakeStringException(-1, "private key file not specified in config file");
createSecureSocketContextSecretSrv_t xproc = (createSecureSocketContextSecretSrv_t) pplg->getProcAddress("createSecureSocketContextSecretSrv");
if (!xproc)
throw MakeStringException(-1, "procedure createSecureSocketContextSecretSrv can't be loaded");
m_ssctx.setown(xproc(issuer, false));
}

createSecureSocketContextEx2_t xproc = NULL;
IEspPlugin *pplg = loadPlugin(SSLIB);
if (pplg)
xproc = (createSecureSocketContextEx2_t) pplg->getProcAddress("createSecureSocketContextEx2");
else
throw MakeStringException(-1, "dll/shared-object %s can't be loaded", SSLIB);


if (xproc)
{
//ensure keys are specified. Passphrase is optional
StringBuffer sb;
cfg->getProp("certificate", sb);
if(sb.isEmpty())
throw MakeStringException(-1, "certificate file not specified in config file");

cfg->getProp("privatekey", sb.clear());
if(sb.isEmpty())
throw MakeStringException(-1, "private key file not specified in config file");

createSecureSocketContextEx2_t xproc = (createSecureSocketContextEx2_t) pplg->getProcAddress("createSecureSocketContextEx2");
if (!xproc)
throw MakeStringException(-1, "procedure createSecureSocketContextEx2 can't be loaded");
m_ssctx.setown(xproc(cfg, ServerSocket));
else
throw MakeStringException(-1, "procedure createSecureSocketContextEx2 can't be loaded");
}
}
}

Expand Down
1 change: 1 addition & 0 deletions helm/hpcc/templates/esp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ data:
tls: {{ include "hpcc.isIssuerEnabled" (dict "root" .root "issuerKeyName" $issuerKeyName) }}
{{- end }}
tls_config:
issuer: {{ $issuerKeyName }}
{{- if $externalCert }}
certificate: /opt/HPCCSystems/secrets/certificates/{{ $issuerKeyName }}/tls.crt
privatekey: /opt/HPCCSystems/secrets/certificates/{{ $issuerKeyName }}/tls.key
Expand Down
4 changes: 2 additions & 2 deletions system/security/securesocket/securesocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2014,11 +2014,11 @@ SECURESOCKET_API ISecureSocketContext* createSecureSocketContextSecret(const cha
SECURESOCKET_API ISecureSocketContext* createSecureSocketContextSecretSrv(const char *issuer, bool requireMtlsFlag)
{
if (requireMtlsFlag && !queryMtls())
throw makeStringException(-100, "TLS secure communication requested but not configured");
throw makeStringException(-100, "MTLS secure context required but not configured");

Owned<const ISyncedPropertyTree> info = getIssuerTlsSyncedConfig(issuer);
if (!info->isValid())
throw makeStringException(-101, "TLS secure communication requested but not configured (2)");
throw makeStringExceptionV(-101, "TLS issuer %s secure context requested but not configured (2)", issuer);

return createSecureSocketContextSynced(info, ServerSocket);
}
Expand Down
1 change: 1 addition & 0 deletions system/security/securesocket/securesocket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ typedef ISecureSocketContext* (*createSecureSocketContext_t)(SecureSocketType);
typedef ISecureSocketContext* (*createSecureSocketContextEx_t)(const char* certFileOrBuf, const char* privKeyFileOrBuf, const char* passphrase, SecureSocketType);
typedef ISecureSocketContext* (*createSecureSocketContextEx2_t)(IPropertyTree* config, SecureSocketType);
typedef ISecureSocketContext* (*createSecureSocketContextSecret_t)(const char *mtlsSecretName, SecureSocketType);
typedef ISecureSocketContext* (*createSecureSocketContextSecretSrv_t)(const char *mtlsSecretName, bool requireMtlsConfig);

extern "C" {

Expand Down