Skip to content

Commit

Permalink
Add first example
Browse files Browse the repository at this point in the history
  • Loading branch information
timokoessler committed Jan 2, 2024
1 parent 61cad23 commit 9850259
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions examples/url.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { getCertStatusByDomain } from '../dist';

(async () => {
try {
const ocspResult = await getCertStatusByDomain('https://www.github.com');
switch (ocspResult.status) {
case 'good':
console.log('Certificate is valid');
break;
case 'unknown':
console.warn('Certificate status is unknown');
break;
case 'revoked':
console.log(`Certificate was revoked at ${ocspResult.revocationTime}`);
if (ocspResult.revocationReason) {
console.log(`Revocation reason: ${ocspResult.revocationReason}`);
}
break;
}
} catch (e) {
console.error(e);
}
})();

0 comments on commit 9850259

Please sign in to comment.