Skip to content

Commit b354cf6

Browse files
committed
status: add cert
1 parent ca90766 commit b354cf6

File tree

5 files changed

+22
-3
lines changed

5 files changed

+22
-3
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ jobs:
1818
- name: Set up Node.js
1919
uses: actions/setup-node@v4
2020
with:
21-
node-version: 20
21+
node-version: 22
2222

2323
- name: Build status page
2424
working-directory: framework/ndn-testbed-status
2525
run: |
26-
npm install
26+
npm ci
2727
npm run build
2828
2929
- name: Deploy

framework/ndn-testbed-status/src/App.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<th>Last Refresh</th>
1111
<th>TLS Expiry</th>
1212
<th>WSS</th>
13+
<th>Site Cert</th>
1314
<th>Revision</th>
1415

1516
<th v-for="node in routers">{{ node.shortname }}</th>
@@ -55,6 +56,12 @@
5556
}">
5657
{{ router.status?.['ws-tls'] ? 'OK' : '' }}
5758
</td>
59+
<td :class="{
60+
forceshort: true,
61+
warning: (router.status?.site_cert_expiry ?? -1) < 0,
62+
okay: getFromNow(router.status?.site_cert_expiry ?? -1) > 7 * 86400,
63+
}" :title="router.status?.tls?.error ?? ''"
64+
>{{ getFromNowStr(router.status?.site_cert_expiry, 'days') }}</td>
5865
<td>
5966
<a v-if="router.status?.revision"
6067
:href="getRevUrl(router)"

framework/ndn-testbed-status/src/testbed.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ interface IStatus {
2626
error: string | null,
2727
},
2828
'ws-tls': boolean,
29+
site_cert_expiry: number,
2930
services: Record<string, {
3031
image: string;
3132
status: string;

framework/status-json.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,15 @@ def get_ws_tls_status(host: dict) -> bool:
126126
except urllib.request.HTTPError as response:
127127
return response.code == 426
128128

129+
def get_ndn_cert_expiry(cert_path: str) -> int:
130+
print(f'Getting expirty for {cert_path}', file=sys.stderr)
131+
try:
132+
cmd = ['python3', '/testbed/scripts/cert-check.py', cert_path]
133+
output = subprocess.check_output(cmd, timeout=5)
134+
return int(output.strip())
135+
except subprocess.CalledProcessError as e:
136+
return 0
137+
129138
if __name__ == '__main__':
130139
config = conf.get()
131140

@@ -147,6 +156,7 @@ def get_ws_tls_status(host: dict) -> bool:
147156
'host_info': run_safe(get_host_info),
148157
'tls': run_safe(get_tls_status, host),
149158
'ws-tls': run_safe(get_ws_tls_status, host),
159+
'site_cert_expiry': run_safe(get_ndn_cert_expiry, "/testbed/dist/ndncert/site.ndncert"),
150160
'services': run_safe(get_services),
151161
'nfd': run_safe(get_nfd),
152162
'nlsr': run_safe(get_nlsr),

scripts/cert-check.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ def main():
2727
not_after = bytes(cert.signature_info.validity_period.not_after).decode()
2828
not_after = datetime.strptime(not_after, date_template)
2929

30-
print("Cert Status", file_path, not_before, not_after)
30+
# Print expiration date in seconds since epoch
31+
print(int(not_after.timestamp()))
3132

3233
now = datetime.now()
3334
if not_before <= now <= not_after - timedelta(days=91):

0 commit comments

Comments
 (0)