Skip to content

Commit

Permalink
Fix in httpClient for ssl options and allow queueexecutor independent…
Browse files Browse the repository at this point in the history
… execution
  • Loading branch information
TekMonksGitHub committed Jun 3, 2024
1 parent 145f28a commit 200cfce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions backend/server/lib/httpClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function _doCall(reqStr, options, secure, sslObj) {
const caller = secure && (!sslObj?._org_monkshu_httpclient_forceHTTP1) ? http2.connect(`https://${options.host}:${options.port||443}`) :
secure ? https : http; // use the right connection factory based on http2, http1/ssl or http1/http
let resp, ignoreEvents = false, resPiped, _skipProtocolErrors = false;
if (sslObj & typeof sslObj == "object") try { await _addSecureOptions(options, sslObj) } catch (err) { reject(err); return; };
if (sslObj && typeof sslObj == "object") try { await _addSecureOptions(options, sslObj) } catch (err) { reject(err); return; };
const sendError = (error) => {
reject(error); ignoreEvents = true;
};
Expand Down Expand Up @@ -210,7 +210,7 @@ function _doCall(reqStr, options, secure, sslObj) {
} else {
LOG.info(`httpClient connecting to URL ${options.host}:${options.port}/${options.path} via HTTP1.`);

if (sslObj & typeof sslObj == "object") try{await _addSecureOptions(options, sslObj)} catch (err) {reject(err); return;};
if (sslObj && typeof sslObj == "object") try{await _addSecureOptions(options, sslObj)} catch (err) {reject(err); return;};
const req = caller.request(options, res => {
if (!_checkRequestResponseContentTypesMatch(options.headers, res.headers)) {
sendError(`Content type doesn't match acceptable content. Requested ${options.headers.accept} != ${res.headers["content-type"]}.`);
Expand Down Expand Up @@ -263,6 +263,8 @@ async function _addSecureOptions(options, sslObj) {
options.cert = await _cacheReadFile(ssl.certPath);
options.key = crypt.decrypt(await _cacheReadFile(ssl.encryptedKeyPath), sslObj.encryptionKey);
}

if (sslObj.rejectUnauthorized !== undefined) options.rejectUnauthorized = sslObj.rejectUnauthorized;
}

module.exports = { get, post, put, delete: deleteHttp, getHttps, postHttps, putHttps, deleteHttps, fetch, main };
Expand Down
2 changes: 1 addition & 1 deletion backend/server/lib/queueExecutor.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

const queue = [];
const DEFAULT_QUEUE_CHECK_INTERVAL = 500;
const conf = require(`${CONSTANTS.CONFDIR}/queueexecutor.json`);
let conf; try {conf = require(`${CONSTANTS.CONFDIR}/queueexecutor.json`)} catch (err) {conf = {enabled: true}};

let queueInitialized = false; // to support server independent apps

Expand Down

0 comments on commit 200cfce

Please sign in to comment.