Skip to content

Commit

Permalink
Extract curve array from yaml and make a list of mapped number strings
Browse files Browse the repository at this point in the history
Signed-off-by: Gautham Kuppuswamy <[email protected]>
  • Loading branch information
Gautham-coder committed Jul 30, 2024
1 parent 05fc40f commit 6c1643f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
38 changes: 38 additions & 0 deletions c/zss.c
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,7 @@ static char* generateCookieNameV2(ConfigManager *configmgr, int port) {
#define ENV_AGENT_HTTPS_KEY(key) AGENT_HTTPS_PREFIX key

TLS_IANA_CIPHER_MAP(ianaCipherMap)
TLS_IANA_CURVE_MAP(ianaCurveMap)

static bool readAgentHttpsSettingsV2(ShortLivedHeap *slh,
ConfigManager *configmgr,
Expand Down Expand Up @@ -1226,6 +1227,43 @@ static bool readAgentHttpsSettingsV2(ShortLivedHeap *slh,

}

Json *tlsConfig = NULL;
int tlsGetStatus = cfgGetAnyC(configmgr,ZSS_CFGNAME,&tlsConfig, 4,"zowe","network","server","tls");
if (tlsGetStatus) {
zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_INFO, "TLS is NOT configured for this ZSS\n");
} else {
JsonObject *tlsConfigObject = jsonAsObject(tlsConfig);
Json *curveJson = jsonObjectGetPropertyValue(tlsConfigObject, "curves");
char *curves = NULL;
if(jsonIsArray(curveJson)) {
JsonArray *curveArray = jsonObjectGetArray(tlsConfigObject, "curves");
int count = jsonArrayGetCount(curveArray);

int curveCharLength = 4;
curves = (char *)safeMalloc((sizeof(char) * curveCharLength * count)+1, "curve list");
for (int i = 0; i < count; i++) {
char *ianaName = jsonArrayGetString(curveArray, i);
zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG, "curve request=%s\n", ianaName);
CurveMap *curve = (CurveMap *)ianaCurveMap;
bool found = false;
while (curve->groupId != NULL) {
if (!strcmp(ianaName, curve->name)) {
strcat(curves, curve->groupId);
zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG, "Curve match=%s\n", curve->groupId);
found = true;
break;
}
++curve;
}
if (!found) {
zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_WARNING, ZSS_LOG_CURVE_INVALID_MSG, ianaName);
printf("ZSS_LOG_CURVE_INVALID_MSG\n");
}
}
zowelog(NULL, LOG_COMP_ID_MVD_SERVER, ZOWE_LOG_DEBUG, "Curve array override to %s\n", curves);
}
}

ECVT *ecvt = getECVT();
/*
2.3 (1020300) no tls 1.3
Expand Down
2 changes: 1 addition & 1 deletion deps/zowe-common-c
6 changes: 6 additions & 0 deletions h/zssLogging.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,12 @@ bool isLogLevelValid(int level);
#define ZSS_LOG_CIPHER_INVALID_MSG_TEXT "Requested cipher '%s' not available.\n"
#define ZSS_LOG_CIPHER_INVALID_MSG ZSS_LOG_CIPHER_INVALID_MSG_ID" "ZSS_LOG_CIPHER_INVALID_MSG_TEXT

#ifndef ZSS_LOG_CURVE_INVALID_MSG_ID
#define ZSS_LOG_CURVE_INVALID_MSG_ID ZSS_LOG_MSG_PRFX"1067W"
#endif
#define ZSS_LOG_CURVE_INVALID_MSG_TEXT "Requested curve '%s' not available.\n"
#define ZSS_LOG_CURVE_INVALID_MSG ZSS_LOG_CURVE_INVALID_MSG_ID" "ZSS_LOG_CURVE_INVALID_MSG_TEXT


/* registerProduct */

Expand Down

0 comments on commit 6c1643f

Please sign in to comment.