ssl-validator
Advanced tools
Comparing version 1.0.5 to 1.0.6
# SSL Validator Changelog | ||
## 1.0.6 - 2020-02-25 | ||
- update ramda dependency to `0.27.0` | ||
- added missing async keyword to the function validateSSLKey | ||
- fixed domainRegTest and added tests around validation of domains to wildcard certs | ||
- Update development/test dependencies | ||
- Update pem dependency | ||
- Add Node 11, 12, and 13 to travis.yml | ||
- Remove Node 8 and 9 from travis.yml (since mocha/eslint no longer support them). Note that ssl-validator itself still works on node 8/9. | ||
*** | ||
@@ -4,0 +14,0 @@ |
@@ -26,4 +26,4 @@ const { | ||
const domainRegTest = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9]$)/; | ||
const checkDomainTest = domainRegTest.test.bind(domainRegTest); | ||
const domainSegmentTest = /^[A-Za-z0-9-]{1,63}$/; | ||
const checkDomainSegment = domainSegmentTest.test.bind(domainSegmentTest); | ||
@@ -36,3 +36,4 @@ const isDomainMatch = curry((toCheck, base) => { | ||
if (!toCheck.endsWith(base)) { return false; } // it's not a subdomain | ||
if (!checkDomainTest(toCheck.slice(0, -base.length))) { return false; } | ||
const domainSegment = toCheck.slice(0, -base.length); | ||
if (domainSegment.startsWith('-') || domainSegment.endsWith('-') || !checkDomainSegment(domainSegment)) { return false; } | ||
return true; | ||
@@ -39,0 +40,0 @@ }); |
@@ -42,3 +42,3 @@ const { find, trim, isNil, mergeRight } = require('ramda'); | ||
const validateSSLKey = (key) => { | ||
const validateSSLKey = async (key) => { | ||
key = trim(String(key)); | ||
@@ -45,0 +45,0 @@ if (!isKeyValidFormat(key)) { |
{ | ||
"name": "ssl-validator", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Validator for certificates, bundles, and keys", | ||
@@ -40,10 +40,10 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"pem": "^1.14.2", | ||
"ramda": "^0.26.1" | ||
"pem": "^1.14.4", | ||
"ramda": "^0.27.0" | ||
}, | ||
"devDependencies": { | ||
"@losant/eslint-config-losant": "^1.3.6", | ||
"husky": "^2.7.0", | ||
"lint-staged": "^8.2.1", | ||
"mocha": "^5.2.0", | ||
"@losant/eslint-config-losant": "^1.3.11", | ||
"husky": "^4.2.3", | ||
"lint-staged": "^10.0.8", | ||
"mocha": "^7.0.1", | ||
"should": "^13.2.3" | ||
@@ -58,3 +58,8 @@ }, | ||
} | ||
}, | ||
"mocha": { | ||
"reporter": "spec", | ||
"recursive": true, | ||
"check-leaks": true | ||
} | ||
} |
@@ -37,2 +37,4 @@ # Node SSL Validator | ||
```javascript | ||
const { validateSSL } = require('ssl-validator'); | ||
await validateSSL(cert, options); | ||
@@ -53,2 +55,4 @@ ``` | ||
```javascript | ||
const { validateSSLCert } = require('ssl-validator'); | ||
await validateSSLCert(cert, options); | ||
@@ -66,2 +70,4 @@ ``` | ||
```javascript | ||
const { validateSSLKey } = require('ssl-validator'); | ||
await validateSSLKey(key); | ||
@@ -75,2 +81,4 @@ ``` | ||
```javascript | ||
const { validateCertBundle } = require('ssl-validator'); | ||
await validateCertBundle(cert, bundle, options); | ||
@@ -88,2 +96,4 @@ ``` | ||
```javascript | ||
const { validateCertKeyPair } = require('ssl-validator'); | ||
await validateCertKeyPair(cert, key, options); | ||
@@ -101,2 +111,4 @@ ``` | ||
```javascript | ||
const { validateCertToDomain } = require('ssl-validator'); | ||
await validateCertToDomain(cert, domain, options); | ||
@@ -123,2 +135,4 @@ ``` | ||
```javascript | ||
const { isValidSSL } = require('ssl-validator'); | ||
if (!(await isValidSSL(cert))) { | ||
@@ -125,0 +139,0 @@ return { message: 'Sorry, the certificate supplied is not valid.' }; |
@@ -0,1 +1,52 @@ | ||
module.exports.validWildCardKey = `-----BEGIN PRIVATE KEY----- | ||
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC6iTFLz75M9XxU | ||
TdX/xIh3mQSchRPQI5b3F6NbIfNxGCif8+cJznwMn54mMA+qeYFvyXUBIB8blU6O | ||
3/xx3NpbplL6QWI+Ck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ncDpGjsLMNm3VpiNnl/BaHSDex2SJl0mK5CCypuMjr585J77k3obOcw1bFGx6ues | ||
vtr1hMFwacq64H6VJ/DHpoVQrEHZoba+n6ISPU4WY6A/QXmZK6x7IXzsqwKBgGZT | ||
s+tTj7lBiAK7vqZFI6QoNNoOyERt5VDJY/1qnGG+I2FyAFRU3ytjekw5fC0dJC1W | ||
E+bFzgdfL4OF5r+e+nFV5SBKIumg83Oq/j5RQHsgIqrexrJ+IlJxN2vXX1ebS+KN | ||
08syiE1TdlhKowmqaYFHhZHIYefxc+WgGDG2AgYxAoGACmN1Fc/I0zVCpD9trh2S | ||
fI9hdC4kp/cDNfPaiwrcC4bjEJgwCrCpOilAaQ81oQ7Y1S1e5BSbi37x4am1HFSH | ||
QKRxcbdxtsdjF3+YxI6r3FUvqQVNflILl+XORntuEV53jMnzPsqtcIhF3yeoAxBw | ||
UuByDE2vZ2EE7Scz2CHYL0E= | ||
-----END PRIVATE KEY-----`; | ||
module.exports.validWildCardCert = `-----BEGIN CERTIFICATE----- | ||
MIIDiDCCAnACCQC/5MoAGtoZyTANBgkqhkiG9w0BAQsFADCBhTELMAkGA1UEBhMC | ||
VVMxCzAJBgNVBAgMAk9IMRMwEQYDVQQHDApDaW5jaW5uYXRpMQ8wDQYDVQQKDAZM | ||
b3NhbnQxDTALBgNVBAsMBFRlc3QxEjAQBgNVBAMMCSoueHh4LmNvbTEgMB4GCSqG | ||
SIb3DQEJARYRbXllbWFpbEBnbWFpbC5jb20wHhcNMjAwMjI1MjMxODE5WhcNMjEw | ||
MjI0MjMxODE5WjCBhTELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAk9IMRMwEQYDVQQH | ||
DApDaW5jaW5uYXRpMQ8wDQYDVQQKDAZMb3NhbnQxDTALBgNVBAsMBFRlc3QxEjAQ | ||
BgNVBAMMCSoueHh4LmNvbTEgMB4GCSqGSIb3DQEJARYRbXllbWFpbEBnbWFpbC5j | ||
b20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC6iTFLz75M9XxUTdX/ | ||
xIh3mQSchRPQI5b3F6NbIfNxGCif8+cJznwMn54mMA+qeYFvyXUBIB8blU6O3/xx | ||
3NpbplL6QWI+Ck07ZdCPZp33tPN65DZ/7SbWXVi4szzQlPZhlmFiIPCqlRU8Lo/F | ||
cF/JXAHjk+1tJ61ZWhiqM3721h8L4/o3nkDjtVgr0rn1t1yr5fgGcB/HaB70oNEO | ||
Bh17cRB4yKBej5lnOH/U9cDXPsUBLZaWOJ2IQX4NZZwYnINfDa97xkLYrwC0Z+e6 | ||
EVxXyAgHMRM29KDfuwLoFGuOEj3xX0G8JlF9uYegy3u4y486B2/HA+NagtW0wUfl | ||
qwBPAgMBAAEwDQYJKoZIhvcNAQELBQADggEBAKnGjfntho1liTz/7+D/B5/xmEFN | ||
kYGpME7lhKWyep83ycMAVKi+wouDh6XiQ9EfUYvzfthD89qNxFvX/zdWWk1oaSR2 | ||
xGNmrU0B8V+TbCxHvTS13B07HU+Pj4CScFVrkLh4TLKQReDmaSHvj/l2YlOIFFs+ | ||
Xk84rWz66PB6+jD7K2p3OhbyicygWAw4O1oOtsH/SU6ER4w7c4a0c4fHesf/9Fjl | ||
1JjW/B+Zd2uyIq6cJ7386bJamcufCuigO5iV0CmN+lmq3Pui/ulktZH5v4AhJiwT | ||
sc3VIgKc8Q/H0CEONLX4hX8Hu1ucRhiIGcTT+x5N9tEr9i4BVGSrr6T2Hdk= | ||
-----END CERTIFICATE-----`; | ||
module.exports.validCert = `-----BEGIN CERTIFICATE----- | ||
@@ -2,0 +53,0 @@ MIIDBzCCAe+gAwIBAgIJAPb5ShpCQoPwMA0GCSqGSIb3DQEBBQUAMBoxGDAWBgNV |
@@ -9,3 +9,5 @@ const should = require('should'); | ||
badCert, | ||
badKey | ||
badKey, | ||
validWildCardCert, | ||
validWildCardKey | ||
} = require('./__fixtures__/valid-ssl'); | ||
@@ -32,2 +34,13 @@ | ||
}); | ||
it('should validate with wildcard cert', async () => { | ||
(await Validation.isValidSSL(validWildCardCert, { key: validWildCardKey, domain: 'm.xxx.com', skipDateValidation: false })).should.be.true(); | ||
(await Validation.isValidSSL(validWildCardCert, { key: validWildCardKey, domain: 'xxx.com', skipDateValidation: false })).should.be.false(); | ||
(await Validation.isValidSSL(validWildCardCert, { key: validWildCardKey, domain: '.xxx.com', skipDateValidation: false })).should.be.false(); | ||
(await Validation.isValidSSL(validWildCardCert, { key: validWildCardKey, domain: 'foo.bar.xxx.com', skipDateValidation: false })).should.be.false(); | ||
(await Validation.isValidSSL(validWildCardCert, { key: validWildCardKey, domain: 'foobar.xxx.com', skipDateValidation: false })).should.be.true(); | ||
(await Validation.isValidSSL(validWildCardCert, { key: validWildCardKey, domain: '-foo.xxx.com', skipDateValidation: false })).should.be.false(); | ||
(await Validation.isValidSSL(validWildCardCert, { key: validWildCardKey, domain: '-foo-.xxx.com', skipDateValidation: false })).should.be.false(); | ||
(await Validation.isValidSSL(validWildCardCert, { key: validWildCardKey, domain: 'foo-.xxx.com', skipDateValidation: false })).should.be.false(); | ||
(await Validation.isValidSSL(validWildCardCert, { key: validWildCardKey, domain: ' .xxx.com', skipDateValidation: false })).should.be.false(); | ||
}); | ||
}); | ||
@@ -55,42 +68,33 @@ describe('#isValid function should return true', () => { | ||
should.exist(result); | ||
result.issuer.should.deepEqual({ | ||
country: '', | ||
state: '', | ||
locality: '', | ||
organization: '', | ||
organizationUnit: '', | ||
commonName: 'mycustomguy.com', | ||
dc: '' | ||
}); | ||
}); | ||
it('#validateSSLCert should throw error when formatting is wrong', async () => { | ||
let error; | ||
try { | ||
await Validation.validateSSLCert(''); | ||
} catch (e) { | ||
error = e; | ||
} | ||
error.message.should.equal('Certificate must start and end with proper formatting.'); | ||
await Validation.validateSSLCert('').should.be.rejectedWith({ | ||
message: 'Certificate must start and end with proper formatting.' | ||
}); | ||
}); | ||
it('#validateSSLCert should throw error when formatted correctly but cert is still bad', async () => { | ||
let error; | ||
try { | ||
await Validation.validateSSLCert(badCert); | ||
} catch (e) { | ||
error = e; | ||
} | ||
should.exist(error.message); | ||
await Validation.validateSSLCert(badCert).should.be.rejected(); | ||
}); | ||
it('#validateSSLKey', async () => { | ||
const result = await Validation.validateSSLKey(validKey); | ||
should.exist(result); | ||
result.should.deepEqual({ | ||
modulus: 'B0CBB05C2655CA93076A298B2386E0D1FEF8647E062E5293317B1A4BBE21E4693367E6C4B1C983AE8C8CEE03D7128735F1D7FE79E70A1B5C3453D820B7EF683AA743B970810D03F29B0DA8337F1D84BEF37E640846CA812424B4CE1522A3F5DBE85E789E5172201B7A028CA8A49141E3EAC90FF2F180F60134A20CBF811CF26217B4A9BA51592FDDF4F1DB776F88BBD5EFD227127C8EDFA56AB3E901E7F29F29669EAB3A8D6396B7CF74DF3683BEFE86E4D1AC99138A68FAA93194B1290BC25F4DFDF517686A9C2895B532C15851A2C5BAB2199155EED2700CBCD1FB2FBCAB0E49C3F17AFDD47119085F187681BB5834FC13787528BB65D8D558899A6B550147' | ||
}); | ||
}); | ||
it('#validateSSLKey should throw error when formatting is wrong', async () => { | ||
let error; | ||
try { | ||
await Validation.validateSSLKey(''); | ||
} catch (e) { | ||
error = e; | ||
} | ||
error.message.should.equal('Key must start and end with proper formatting.'); | ||
await Validation.validateSSLKey('').should.be.rejectedWith({ | ||
message: 'Key must start and end with proper formatting.' | ||
}); | ||
}); | ||
it('#validateSSLKey should throw error when formatted correctly but key is still bad', async () => { | ||
let error; | ||
try { | ||
await Validation.validateSSLKey(badKey); | ||
} catch (e) { | ||
error = e; | ||
} | ||
should.exist(error.message); | ||
await Validation.validateSSLKey(badKey).should.be.rejected(); | ||
}); | ||
@@ -102,9 +106,5 @@ it('#validateCertToDomain', async () => { | ||
it('#validateCertToDomain should throw an error when it does not match', async () => { | ||
let error; | ||
try { | ||
await Validation.validateCertToDomain(validCert, '*'); | ||
} catch (e) { | ||
error = e; | ||
} | ||
error.message.should.equal('The certificate does not match the domain.'); | ||
await Validation.validateCertToDomain(validCert, '*').should.be.rejectedWith({ | ||
message: 'The certificate does not match the domain.' | ||
}); | ||
}); | ||
@@ -116,9 +116,5 @@ it('#validateCertKeyPair', async () => { | ||
it('#validateCertKeyPair should error when they do not match.', async () => { | ||
let error; | ||
try { | ||
await Validation.validateCertKeyPair(validCert, nonMatchingKey); | ||
} catch (e) { | ||
error = e; | ||
} | ||
error.message.should.equal('The provided certificate and key do not match.'); | ||
await Validation.validateCertKeyPair(validCert, nonMatchingKey).should.be.rejectedWith({ | ||
message: 'The provided certificate and key do not match.' | ||
}); | ||
}); | ||
@@ -130,11 +126,7 @@ it('#validateCertBundle', async () => { | ||
it('#validateCertBundle should throw an error when they do not match', async () => { | ||
let error; | ||
try { | ||
await Validation.validateCertBundle(validCert, validBundle); | ||
} catch (e) { | ||
error = e; | ||
} | ||
error.message.should.equal('Bundle does not match the certificate.'); | ||
await Validation.validateCertBundle(validCert, validBundle).should.be.rejectedWith({ | ||
message: 'Bundle does not match the certificate.' | ||
}); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
629
139
38778
14
+ Addedramda@0.27.2(transitive)
- Removedramda@0.26.1(transitive)
Updatedpem@^1.14.4
Updatedramda@^0.27.0