File: validity-dates.lisp

package info (click to toggle)
acl2 8.6%2Bdfsg-2
  • links: PTS
  • area: main
  • in suites: trixie
  • size: 1,111,420 kB
  • sloc: lisp: 17,818,294; java: 125,359; python: 28,122; javascript: 23,458; cpp: 18,851; ansic: 11,569; perl: 7,678; xml: 5,591; sh: 3,976; makefile: 3,833; ruby: 2,633; yacc: 1,126; ml: 763; awk: 295; csh: 233; lex: 197; php: 178; tcl: 49; asm: 23; haskell: 17
file content (32 lines) | stat: -rw-r--r-- 1,220 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
;;;; -*- Mode: LISP; Syntax: COMMON-LISP; indent-tabs-mode: nil; coding: utf-8; show-trailing-whitespace: t -*-
;;;
;;; Copyright (C) contributors as per cl+ssl git history
;;;
;;; See LICENSE for details.

(in-package :cl+ssl.test)

(def-suite :cl+ssl.validity-dates :in :cl+ssl
  :description "Validity date tests")

(in-suite :cl+ssl.validity-dates)

(test validity-dates-google-cert
  (when (and (cl+ssl::openssl-is-at-least 1 1 0)
             (not  (cl+ssl::libresslp)))
    (with-cert ("google.der" cert)
      (is (= (cl+ssl:certificate-not-after-time cert)
             3641760000))
      (is (= (cl+ssl:certificate-not-before-time cert)
             3634055286)))))

(test validity-dates-after-2050
  "Make sure we handle dates after 2050, which are encoded in ASN1 as a
GeneralizedTime, whereas dates before 2050 are encoded as UTCTime."
  (when (and (cl+ssl::openssl-is-at-least 1 1 0)
             (not  (cl+ssl::libresslp)))
    (with-cert ("mixed-time-formats.der" cert)
      (is (= (cl+ssl:certificate-not-before-time cert)
             (encode-universal-time 04 25 11 20 11 2021 0)))
      (is (= (cl+ssl:certificate-not-after-time cert)
             (encode-universal-time 04 25 11 20 11 2071 0))))))