@@ -6,7 +6,7 @@ import * as x509 from '@peculiar/x509';
66
77import { HardenedHttpsAgent } from 'hardened-https-agent' ;
88
9- import { getLocal } from '..' ;
9+ import { getLocal , getCertificateTransparencyLogs } from '..' ;
1010import { expect , nodeOnly } from "./test-utils" ;
1111
1212import { getCA , CA } from '../src/util/certificates' ;
@@ -111,6 +111,26 @@ nodeOnly(() => {
111111 expect ( logs8 [ 1 ] . logId ) . to . deep . equal ( logs1 [ 1 ] . logId ) ;
112112 } ) ;
113113
114+ it ( "exposes the CA's CT logs publicly (from the cert alone), matching what is embedded" , async ( ) => {
115+ const cert = await caCert ;
116+ const ca = await getCA ( { key : await caKey , cert, certificateTransparency : true } ) ;
117+
118+ const published = getCertificateTransparencyLogs ( cert ) ;
119+ const embedded = ca . getCTLogDetails ( ) ;
120+
121+ expect ( published ) . to . have . length ( 2 ) ;
122+ expect ( published [ 0 ] . logId ) . to . have . length ( 32 ) ; // SHA-256 of the SPKI
123+ expect ( published [ 0 ] . logId ) . to . deep . equal ( embedded [ 0 ] . logId ) ;
124+ expect ( published [ 0 ] . publicKey ) . to . deep . equal ( embedded [ 0 ] . publicKey ) ;
125+ expect ( published [ 1 ] . logId ) . to . deep . equal ( embedded [ 1 ] . logId ) ;
126+ expect ( published [ 1 ] . publicKey ) . to . deep . equal ( embedded [ 1 ] . publicKey ) ;
127+
128+ // usableSince is the CA cert's notBefore (safe: <= every backdated SCT):
129+ const caNotBefore = new x509 . X509Certificate ( cert ) . notBefore ;
130+ expect ( published [ 0 ] . usableSince . getTime ( ) ) . to . equal ( caNotBefore . getTime ( ) ) ;
131+ expect ( published [ 1 ] . usableSince . getTime ( ) ) . to . equal ( caNotBefore . getTime ( ) ) ;
132+ } ) ;
133+
114134 it ( "getCTLogDetails throws when CT is not enabled" , async ( ) => {
115135 const ca = await getCA ( { key : await caKey , cert : await caCert } ) ;
116136 expect ( ( ) => ca . getCTLogDetails ( ) ) . to . throw ( 'CT not enabled' ) ;
0 commit comments