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';
7
7
import { SERVER_VERSION } from "../constants" ;
8
8
import { delay } from '../util/promise' ;
9
9
import { logError , addBreadcrumb } from '../error-tracking' ;
10
+
10
11
import { HtkConfig } from "../config" ;
11
12
import { ActivationError , Interceptor } from "../interceptors" ;
12
13
import { getDnsServer } from '../dns-server' ;
14
+ import { getCertExpiry , parseCert } from '../certificates' ;
15
+
13
16
import * as Client from '../client/client-types' ;
14
17
import { HttpClient } from '../client/http-client' ;
15
18
@@ -64,6 +67,9 @@ export class ApiModel {
64
67
return {
65
68
certificatePath : this . config . https . certPath ,
66
69
certificateContent : this . config . https . certContent ,
70
+ certificateExpiry : getCertExpiry (
71
+ parseCert ( this . config . https . certContent )
72
+ ) ,
67
73
68
74
// We could calculate this client side, but it requires node-forge or some
69
75
// 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';
3
3
4
4
export const parseCert = forge . pki . certificateFromPem ;
5
5
6
+ export function getCertExpiry ( cert : forge . pki . Certificate ) : number {
7
+ return cert . validity . notAfter . valueOf ( ) ;
8
+ }
9
+
6
10
export 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 ( ) ;
9
12
}
10
13
11
14
// A series of magic incantations that matches the behaviour of openssl's
You can’t perform that action at this time.
0 commit comments