Skip to content

Add rejectUnauthorized option #135

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ const ClamScan = new NodeClam().init({
active: true, // If true, this module will consider using the clamdscan binary
bypassTest: false, // Check to see if socket is available when applicable
tls: false, // Use plaintext TCP to connect to clamd
rejectUnauthorized: true // Validate TLS certificate (if TLS option enabled)
},
preference: 'clamdscan' // If clamdscan is found and active, it will be used by default
});
Expand Down Expand Up @@ -167,7 +168,8 @@ const ClamScan = new NodeClam().init({
reloadDb: true, // You want your scans to run slow like with clamscan
active: false, // you don't want to use this at all because it's evil
bypassTest: true, // Don't check to see if socket is available. You should probably never set this to true.
tls: true, // Connect to clamd over TLS
tls: true, // Connect to clamd over TLS,
rejectUnauthorized: false // Don't validate TLS certificate. Useful when using self-signed certificates.
},
preference: 'clamscan' // If clamscan is found and active, it will be used by default
});
Expand Down
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class NodeClam {
* @param {boolean} [options.clamdscan.active=true] - If true, this module will consider using the `clamdscan` binary
* @param {boolean} [options.clamdscan.bypassTest=false] - If true, check to see if socket is avaliable
* @param {boolean} [options.clamdscan.tls=false] - If true, connect to a TLS-Termination proxy in front of ClamAV
* @param {boolean} [options.clamdscan.rejectUnauthorized=true] - If true, validates the server's TLS certificate
* @param {object} [options.preference='clamdscan'] - If preferred binary is found and active, it will be used by default
* @param {Function} [cb = null] - Callback method. Prototype: `(err, <instance of NodeClam>)`
* @returns {Promise<object>} An initated instance of NodeClam
Expand Down Expand Up @@ -542,6 +543,7 @@ class NodeClam {
client = tls.connect({
host: this.settings.clamdscan.host,
port: this.settings.clamdscan.port,
rejectUnauthorized: this.settings.clamdscan.rejectUnauthorized,
// Activate SNI
// servername: this.settings.clamdscan.host,
timeout,
Expand All @@ -556,7 +558,11 @@ class NodeClam {
}
// Host can be ignored since the default is `localhost`
else if (this.settings.tls) {
client = tls.connect({ port: this.settings.clamdscan.port, timeout });
client = tls.connect({
port: this.settings.clamdscan.port,
rejectUnauthorized: this.settings.clamdscan.rejectUnauthorized,
timeout
});
} else {
client = net.createConnection({ port: this.settings.clamdscan.port, timeout });
}
Expand Down