File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -7,9 +7,12 @@ import { getSystemProxy } from 'os-proxy-config';
77import { SERVER_VERSION } from "../constants" ;
88import { delay } from '../util/promise' ;
99import { logError , addBreadcrumb } from '../error-tracking' ;
10+
1011import { HtkConfig } from "../config" ;
1112import { ActivationError , Interceptor } from "../interceptors" ;
1213import { getDnsServer } from '../dns-server' ;
14+ import { getCertExpiry , parseCert } from '../certificates' ;
15+
1316import * as Client from '../client/client-types' ;
1417import { HttpClient } from '../client/http-client' ;
1518
@@ -64,6 +67,9 @@ export class ApiModel {
6467 return {
6568 certificatePath : this . config . https . certPath ,
6669 certificateContent : this . config . https . certContent ,
70+ certificateExpiry : getCertExpiry (
71+ parseCert ( this . config . https . certContent )
72+ ) ,
6773
6874 // We could calculate this client side, but it requires node-forge or some
6975 // other heavyweight crypto lib, and we already have that here, so it's
Original file line number Diff line number Diff line change @@ -3,9 +3,12 @@ import * as forge from 'node-forge';
33
44export const parseCert = forge . pki . certificateFromPem ;
55
6+ export function getCertExpiry ( cert : forge . pki . Certificate ) : number {
7+ return cert . validity . notAfter . valueOf ( ) ;
8+ }
9+
610export function getTimeToCertExpiry ( cert : forge . pki . Certificate ) : number {
7- const expiry = cert . validity . notAfter . valueOf ( ) ;
8- return expiry - Date . now ( ) ;
11+ return getCertExpiry ( cert ) - Date . now ( ) ;
912}
1013
1114// A series of magic incantations that matches the behaviour of openssl's
You can’t perform that action at this time.
0 commit comments