Skip to content

Commit 6ad2947

Browse files
committed
add support for skipverifyhost
https://bugzilla.redhat.com/show_bug.cgi?id=1692074 Add ability to specify the libcurl CURLOPT_SSL_VERIFYHOST option to skip verification of the hostname in the peer cert. WARNING: This option is insecure, and should only be used for testing. The default value is off, meaning, the hostname will be verified by default. (cherry picked from commit 6e0ccf89c20edd85848661c882d8c9cd75ff18de)
1 parent 14f6966 commit 6ad2947

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

rsyslog/vendored_src/rsyslog/rsyslog/contrib/mmkubernetes/mmkubernetes.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ struct modConfData_s {
143143
uchar *myCertFile; /* File holding cert corresponding to private key used for client cert auth */
144144
uchar *myPrivKeyFile; /* File holding private key corresponding to cert used for client cert auth */
145145
sbool allowUnsignedCerts; /* For testing/debugging - do not check for CA certs (CURLOPT_SSL_VERIFYPEER FALSE) */
146+
sbool skipVerifyHost; /* For testing/debugging - skip cert hostname verify (CURLOPT_SSL_VERIFYHOST FALSE) */
146147
uchar *token; /* The token value to use to authenticate to Kubernetes - takes precedence over tokenFile */
147148
uchar *tokenFile; /* The file whose contents is the token value to use to authenticate to Kubernetes */
148149
sbool de_dot; /* If true (default), convert '.' characters in labels & annotations to de_dot_separator */
@@ -168,6 +169,7 @@ typedef struct _instanceData {
168169
uchar *myCertFile; /* File holding cert corresponding to private key used for client cert auth */
169170
uchar *myPrivKeyFile; /* File holding private key corresponding to cert used for client cert auth */
170171
sbool allowUnsignedCerts; /* For testing/debugging - do not check for CA certs (CURLOPT_SSL_VERIFYPEER FALSE) */
172+
sbool skipVerifyHost; /* For testing/debugging - skip cert hostname verify (CURLOPT_SSL_VERIFYHOST FALSE) */
171173
uchar *token; /* The token value to use to authenticate to Kubernetes - takes precedence over tokenFile */
172174
uchar *tokenFile; /* The file whose contents is the token value to use to authenticate to Kubernetes */
173175
sbool de_dot; /* If true (default), convert '.' characters in labels & annotations to de_dot_separator */
@@ -223,6 +225,7 @@ static struct cnfparamdescr modpdescr[] = {
223225
{ "tls.mycert", eCmdHdlrString, 0 },
224226
{ "tls.myprivkey", eCmdHdlrString, 0 },
225227
{ "allowunsignedcerts", eCmdHdlrBinary, 0 },
228+
{ "skipverifyhost", eCmdHdlrBinary, 0 },
226229
{ "token", eCmdHdlrString, 0 },
227230
{ "tokenfile", eCmdHdlrString, 0 },
228231
{ "annotation_match", eCmdHdlrArray, 0 },
@@ -255,6 +258,7 @@ static struct cnfparamdescr actpdescr[] = {
255258
{ "tls.mycert", eCmdHdlrString, 0 },
256259
{ "tls.myprivkey", eCmdHdlrString, 0 },
257260
{ "allowunsignedcerts", eCmdHdlrBinary, 0 },
261+
{ "skipverifyhost", eCmdHdlrBinary, 0 },
258262
{ "token", eCmdHdlrString, 0 },
259263
{ "tokenfile", eCmdHdlrString, 0 },
260264
{ "annotation_match", eCmdHdlrArray, 0 },
@@ -637,6 +641,8 @@ CODESTARTsetModCnf
637641
}
638642
} else if(!strcmp(modpblk.descr[i].name, "allowunsignedcerts")) {
639643
loadModConf->allowUnsignedCerts = pvals[i].val.d.n;
644+
} else if(!strcmp(modpblk.descr[i].name, "skipverifyhost")) {
645+
loadModConf->skipVerifyHost = pvals[i].val.d.n;
640646
} else if(!strcmp(modpblk.descr[i].name, "token")) {
641647
free(loadModConf->token);
642648
loadModConf->token = (uchar *) es_str2cstr(pvals[i].val.d.estr, NULL);
@@ -954,6 +960,8 @@ CODESTARTcreateWrkrInstance
954960
curl_easy_setopt(ctx, CURLOPT_SSLKEY, pWrkrData->pData->myPrivKeyFile);
955961
if(pWrkrData->pData->allowUnsignedCerts)
956962
curl_easy_setopt(ctx, CURLOPT_SSL_VERIFYPEER, 0);
963+
if(pWrkrData->pData->skipVerifyHost)
964+
curl_easy_setopt(ctx, CURLOPT_SSL_VERIFYHOST, 0);
957965
#if defined(SUPPORT_SSL_PARTIAL_CHAIN)
958966
if(pWrkrData->pData->sslPartialChain) {
959967
curl_easy_setopt(ctx, CURLOPT_SSL_CTX_FUNCTION, set_ssl_partial_chain);
@@ -1257,6 +1265,7 @@ CODESTARTnewActInst
12571265

12581266
pData->de_dot = loadModConf->de_dot;
12591267
pData->allowUnsignedCerts = loadModConf->allowUnsignedCerts;
1268+
pData->skipVerifyHost = loadModConf->skipVerifyHost;
12601269
pData->busyRetryInterval = loadModConf->busyRetryInterval;
12611270
pData->sslPartialChain = loadModConf->sslPartialChain;
12621271
pData->cacheEntryTTL = loadModConf->cacheEntryTTL;
@@ -1322,6 +1331,8 @@ CODESTARTnewActInst
13221331
}
13231332
} else if(!strcmp(actpblk.descr[i].name, "allowunsignedcerts")) {
13241333
pData->allowUnsignedCerts = pvals[i].val.d.n;
1334+
} else if(!strcmp(actpblk.descr[i].name, "skipverifyhost")) {
1335+
pData->skipVerifyHost = pvals[i].val.d.n;
13251336
} else if(!strcmp(actpblk.descr[i].name, "token")) {
13261337
free(pData->token);
13271338
pData->token = (uchar *) es_str2cstr(pvals[i].val.d.estr, NULL);
@@ -1566,6 +1577,7 @@ CODESTARTdbgPrintInstInfo
15661577
dbgprintf("\ttls.mycert='%s'\n", pData->myCertFile);
15671578
dbgprintf("\ttls.myprivkey='%s'\n", pData->myPrivKeyFile);
15681579
dbgprintf("\tallowUnsignedCerts='%d'\n", pData->allowUnsignedCerts);
1580+
dbgprintf("\tskipVerifyHost='%d'\n", pData->skipVerifyHost);
15691581
dbgprintf("\ttoken='%s'\n", pData->token);
15701582
dbgprintf("\ttokenFile='%s'\n", pData->tokenFile);
15711583
dbgprintf("\tde_dot='%d'\n", pData->de_dot);

rsyslog/vendored_src/rsyslog/rsyslog/plugins/omelasticsearch/omelasticsearch.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ typedef struct instanceConf_s {
138138
size_t maxbytes;
139139
sbool useHttps;
140140
sbool allowUnsignedCerts;
141+
sbool skipVerifyHost;
141142
uchar *caCertFile;
142143
uchar *myCertFile;
143144
uchar *myPrivKeyFile;
@@ -206,6 +207,7 @@ static struct cnfparamdescr actpdescr[] = {
206207
{ "dynpipelinename", eCmdHdlrBinary, 0 },
207208
{ "bulkid", eCmdHdlrGetWord, 0 },
208209
{ "allowunsignedcerts", eCmdHdlrBinary, 0 },
210+
{ "skipverifyhost", eCmdHdlrBinary, 0 },
209211
{ "tls.cacert", eCmdHdlrString, 0 },
210212
{ "tls.mycert", eCmdHdlrString, 0 },
211213
{ "tls.myprivkey", eCmdHdlrString, 0 },
@@ -342,6 +344,7 @@ CODESTARTdbgPrintInstInfo
342344
dbgprintf("\tbulkmode=%d\n", pData->bulkmode);
343345
dbgprintf("\tmaxbytes=%zu\n", pData->maxbytes);
344346
dbgprintf("\tallowUnsignedCerts=%d\n", pData->allowUnsignedCerts);
347+
dbgprintf("\tskipVerifyHost=%d\n", pData->skipVerifyHost);
345348
dbgprintf("\terrorfile='%s'\n", pData->errorFile == NULL ?
346349
(uchar*)"(not configured)" : pData->errorFile);
347350
dbgprintf("\terroronly=%d\n", pData->errorOnly);
@@ -1633,6 +1636,8 @@ curlSetupCommon(wrkrInstanceData_t *const pWrkrData, CURL *const handle)
16331636
curl_easy_setopt(handle, CURLOPT_WRITEDATA, pWrkrData);
16341637
if(pWrkrData->pData->allowUnsignedCerts)
16351638
curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, FALSE);
1639+
if(pWrkrData->pData->skipVerifyHost)
1640+
curl_easy_setopt(handle, CURLOPT_SSL_VERIFYHOST, FALSE);
16361641
if(pWrkrData->pData->authBuf != NULL) {
16371642
curl_easy_setopt(handle, CURLOPT_USERPWD, pWrkrData->pData->authBuf);
16381643
curl_easy_setopt(handle, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
@@ -1707,6 +1712,7 @@ setInstParamDefaults(instanceData *const pData)
17071712
pData->bulkmode = 0;
17081713
pData->maxbytes = 104857600; //100 MB Is the default max message size that ships with ElasticSearch
17091714
pData->allowUnsignedCerts = 0;
1715+
pData->skipVerifyHost = 0;
17101716
pData->tplName = NULL;
17111717
pData->errorFile = NULL;
17121718
pData->errorOnly=0;
@@ -1783,6 +1789,8 @@ CODESTARTnewActInst
17831789
pData->maxbytes = (size_t) pvals[i].val.d.n;
17841790
} else if(!strcmp(actpblk.descr[i].name, "allowunsignedcerts")) {
17851791
pData->allowUnsignedCerts = pvals[i].val.d.n;
1792+
} else if(!strcmp(actpblk.descr[i].name, "skipverifyhost")) {
1793+
pData->skipVerifyHost = pvals[i].val.d.n;
17861794
} else if(!strcmp(actpblk.descr[i].name, "timeout")) {
17871795
pData->timeout = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL);
17881796
} else if(!strcmp(actpblk.descr[i].name, "usehttps")) {

0 commit comments

Comments
 (0)