This repository has been archived by the owner on Oct 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
/
shaaaaa.js
135 lines (114 loc) · 3.7 KB
/
shaaaaa.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
Meant to be run with faucet:
npm install -g faucet
faucet
*/
/*
These tests are not meant to be run often (e.g. via Travis),
as they hit the live internet, and hit domains whose security
properties could change.
They are here to be used during development and debugging,
during which other production testing sites should be used
if something seems to have changed, like SSL Labs.
*/
var test = require("tape");
var shaaaaa = require("../shaaaaa");
var sites = [
{
name: "SHA-1 leaf (requires SNI), sha1-2017.badssl.com",
domain: "sha1-2017.badssl.com",
diagnosis: "bad",
cert: {good: false, algorithm: "sha1"},
intermediates: [
{good: false, algorithm: "sha1"},
{good: true, algorithm: "sha1", root: true}
]
},
{
name: "SHA-2, konklone.com",
domain: "konklone.com",
diagnosis: "good",
cert: {good: true, algorithm: "sha256"},
intermediates: [
{good: true, algorithm: "sha256"},
{good: true, algorithm: "sha1", root: true}
]
},
{
name: "Domain with number and SNI, teacup.p3k.io",
domain: "teacup.p3k.io",
diagnosis: "good",
cert: {good: true, algorithm: "sha256"},
intermediates: [
{good: true, algorithm: "sha256"},
{good: true, algorithm: "sha1", root: true}
]
},
{
name: "Domain with port, konklone.com:443",
domain: "konklone.com:443",
diagnosis: "good",
cert: {good: true, algorithm: "sha256"},
intermediates: [
{good: true, algorithm: "sha256"},
{good: true, algorithm: "sha1", root: true}
]
},
{
name: "Internationalized Domain, domaintest.みんな",
domain: "domaintest.xn--q9jyb4c",
diagnosis: "good",
cert: {good: true, algorithm: "sha256"},
intermediates: [
{good: true, algorithm: "sha256"},
{good: false, algorithm: "sha1"}
]
},
{
name: "Internationalized Domain, اختبارنطاق.شبكة",
domain: "xn--mgbaacjxy2c4fqb.xn--ngbc5azd",
diagnosis: "good",
cert: {good: true, algorithm: "sha256"},
intermediates: [
{good: true, algorithm: "sha256"},
{good: false, algorithm: "sha1"}
]
},
{
name: "SHA-1 root, acus.gov",
domain: "acus.gov",
diagnosis: "good",
cert: {good: true, algorithm: "sha256"},
intermediates: [
{good: true, algorithm: "sha256"},
{good: true, algorithm: "sha256"},
{good: true, algorithm: "sha1", root: true}
]
}
];
sites.forEach(function(site) {
test(site.name, function(t) {
shaaaaa.from(site.domain, function(err, answer) {
if (err) t.fail("Error checking domain: " + err);
t.equal(answer.domain, site.domain, "Domain mismatch.");
t.equal(answer.cert.algorithm, site.cert.algorithm, "Wrong client algorithm.");
t.equal(answer.cert.good, site.cert.good, "Wrong client diagnosis.");
if (site.cert.root) t.ok(answer.cert.root);
if (site.intermediates) {
for (var i=0; i<answer.intermediates.length; i++) {
if (!site.intermediates[i])
t.fail("More certificates returned in server chain than expected.")
else {
t.equal(answer.intermediates[i].good, site.intermediates[i].good, "Intermediate " + i + ": wrong diagnosis.")
t.equal(answer.intermediates[i].algorithm, site.intermediates[i].algorithm, "Intermediate " + i + ": wrong algorithm.")
if (site.intermediates[i].root) t.ok(answer.intermediates[i].root);
if (site.intermediates[i].replacement)
t.equal(answer.intermediates[i].replacement, site.intermediates[i].replacement);
}
}
}
t.equal(answer.diagnosis, site.diagnosis, "Wrong diagnosis: " + answer.diagnosis);
t.end();
});
});
});