Skip to content

Commit f2b7a6c

Browse files
committed
test: window test asserts measured libressl -attime behavior
LibreSSL honors -attime for notBefore but does not enforce notAfter: it accepts an expired certificate at -attime (measured on 3.2.7, same signature in CI on 3.0.2/3.1.5), while OpenSSL refuses it. The previous behavioral gate still entered on libressl because notBefore refusal made the future-certificate probe fail, then the expiry assertion failed. Now the portable core asserts -attime honoring in both directions unconditionally (valid inside its future window, refused at the current time — both libraries agree), and expiry enforcement is asserted per library family. Local gates: 27 CA tests green against openssl 3.5.5, openssl 3.5.9 (CI FIPS job binary) and libressl 3.2.7; full suite 169 passing; FIPS mode 165 passing
1 parent 0f7a8cd commit f2b7a6c

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

‎test/ca.spec.js‎

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -681,14 +681,23 @@ describe('CertificateAuthority', function () {
681681
// inside the window the signature and dates check out
682682
expect(verify(['verify', '-CAfile', caPath, leafPath])).to.equal(0)
683683

684-
// refusal outside the window happens at validation time; gate on the
685-
// library actually enforcing shifted times before asserting it (the
686-
// oldest supported libressl accepts not-yet-valid certificates)
687-
var nowSec = Math.floor(Date.now() / 1000)
688-
if (verify(['verify', '-CAfile', caPath, '-attime', String(nowSec), futurePath]) !== 0) {
689-
// a day after the window closes the certificate is expired again
690-
var late = Math.floor((end.getTime() + 24 * 60 * 60 * 1000) / 1000)
684+
// -attime is honored by every supported library: the future certificate
685+
// is valid inside its own window and not yet valid at the current time
686+
// (measured on OpenSSL 1.1.1-4.x and LibreSSL 3.0.2-3.2.7)
687+
var futureMid = Math.floor((start.getTime() + 7.5 * DAY_MS) / 1000)
688+
expect(verify(['verify', '-CAfile', caPath, '-attime', String(futureMid), futurePath])).to.equal(0)
689+
expect(verify(['verify', '-CAfile', caPath, '-attime', String(Math.floor(Date.now() / 1000)), futurePath])).to.not.equal(0)
690+
691+
// expiry enforcement at validation time is a library capability:
692+
// OpenSSL-family refuses expired certificates at -attime, LibreSSL
693+
// honors -attime for notBefore but accepts expired ones (measured
694+
// on 3.0.2-3.2.7) — both behaviors are asserted below
695+
var late = Math.floor((end.getTime() + 24 * 60 * 60 * 1000) / 1000)
696+
var versionText = spawnSync(process.env.OPENSSL_BIN || 'openssl', ['version']).stdout.toString()
697+
if (versionText.indexOf('LibreSSL') === -1) {
691698
expect(verify(['verify', '-CAfile', caPath, '-attime', String(late), leafPath])).to.not.equal(0)
699+
} else {
700+
expect(verify(['verify', '-CAfile', caPath, '-attime', String(late), leafPath])).to.equal(0)
692701
}
693702
} finally {
694703
fs.rmSync(dir, {recursive: true, force: true})

0 commit comments

Comments
 (0)