CRL
CRL is an acronym for Certificate Revocation List. CRLs are basically "a list of [certificate serial numbers] that have been revoked by the issuing certificate authority (CA) before their scheduled expiration date and should no longer be trusted".
Reading CRLs
use phpseclib4\File\CRL;
$crl = CRL::load(file_get_contents('crl.bin'));
print_r($crl);
$crl, in this case, is a CRL object which, in turn, is basically a thin wrapper around an instance of \phpseclib4\File\ASN1\Constructed. Passing $crl through print_r() or var_dump() triggers the __debugInfo() magic method which, in turn, produces the following output:
tbsCertList
version
phpseclib4\File\ASN1\Types\Integer
signature
algorithm
phpseclib4\File\ASN1\Types\OID
issuer
rdnSequence
0
0
type
phpseclib4\File\ASN1\Types\OID
value
phpseclib4\File\ASN1\Types\PrintableString
1
0
type
phpseclib4\File\ASN1\Types\OID
value
phpseclib4\File\ASN1\Types\PrintableString
2
0
type
phpseclib4\File\ASN1\Types\OID
value
phpseclib4\File\ASN1\Types\PrintableString
3
0
type
phpseclib4\File\ASN1\Types\OID
value
phpseclib4\File\ASN1\Types\PrintableString
thisUpdate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
nextUpdate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
revokedCertificates
0
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
1
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
2
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
3
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
4
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
5
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
6
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
7
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
8
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
9
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
10
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
11
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
12
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
13
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
14
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
15
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
16
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
17
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
18
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
19
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
20
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
21
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
22
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
23
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
24
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
25
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
26
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
27
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
28
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
29
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
30
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
31
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
32
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
33
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
34
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
35
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
36
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
37
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
38
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
39
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
40
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
41
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
42
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
43
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
44
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
45
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
46
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
47
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
48
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
49
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
50
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
51
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
52
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
53
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
54
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
55
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
56
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
57
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
58
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
59
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
60
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
61
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
62
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
63
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
64
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
65
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
66
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
67
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
68
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
69
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
70
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
71
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
72
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
73
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
74
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
75
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
76
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
77
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
78
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
79
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
80
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
81
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
82
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
83
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
84
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
85
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
86
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
87
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
88
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
89
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
90
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
91
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
92
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
93
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
94
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
95
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
96
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
97
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
98
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
99
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
100
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
101
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
102
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
crlExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
keyIdentifier
phpseclib4\File\ASN1\Types\OctetString
1
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
signatureAlgorithm
algorithm
phpseclib4\File\ASN1\Types\OID
signature
phpseclib4\File\ASN1\Types\BitString
All elements and subelements of the above CRL object can be accessed as array elements vis-a-vis ArrayAccess.
To learn more about the capabilities afforded to the CRL class by virtue of it being a thin wrapper around \phpseclib4\File\ASN1\Constructed please refer to Deep Dive: ASN1\Constructed Objects.
listExtensions()
Quoting RFC5280 § 5.2. CRL Extensions:
Conforming CRL issuers are REQUIRED to include the authority key identifier (Section 5.2.1) and the CRL number (Section 5.2.3) extensions in all CRLs issued.
print_r($crl->listExtensions());
Running the above will produce an array with all the attributes that are in the CRL:
0
1
id-ce-authorityKeyIdentifier "is especially useful where an issuer has more than one signing key, either due to multiple concurrent key pairs or due to changeover" (RFC5280 § 5.2.1. Authority Key Identifier)
id-ce-cRLNumber "allows users to easily determine when a particular CRL supersedes another CRL" (RFC5280 § 5.2.3. CRL Number)
getExtension()
Returns an array representing the first instance of an extension even if there are multiple instances. In this array extnId is a string, critical is a boolean and extnValue is an instance of phpseclib4\File\ASN1\Types\BaseType.
If said extension isn't present then null is returned.
print_r($crl->getExtension('id-ce-cRLNumber'));
Since id-ce-cRLNumber exists in $crl, running the above will produce an array with three elements:
extnId
extnValue
phpseclib4\File\ASN1\Types\Integer
critical
You can search by the extension name or the OID for the extension (2.5.29.20, in this case).
If you just want to see if the extension exists you could do getExtension() !== null or you could call hasExtension():
echo $crl->hasExtension('id-ce-cRLNumber') ? 't' : 'f';
hasExtension() works largely the same way that getExtension() does, except that it returns true or false depending on if the extension exists or not.
getDN() / getDNProps()
A CRL has only has an issuer distinguished name (DN for short). The methods for accessing that DN are as follows:
getDN()(alias:getIssuerDN())hasDNProp()(alias:hasIssuerDNProp())getDNProps()(alias:getIssuerDNProps())
Learn more about how DNs work in phpseclib at Deep Dive: Distinguished Names (DNs).
Checking for CRL Inclusion
numRevoked()
The number of revoked certificate serial numbers contained within a CRL can be determined by doing $crl->numRevoked() or count($this->crl['tbsCertList']['revokedCertificates']).
So let's say the CRL in question has 100 revoked certificate serial numbers. You can get the $n'th revoked certificate serial number by doing either $crl->getRevokedByIndex($n) or $this->crl['tbsCertList']['revokedCertificates'][$n]. Doing print_r() on either will give you something like this:
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
userCertificate and revocationDate will always be present - crlEntryExtensions is not guaranteed to be present.
getRevokedAsArray()
$crl->getRevokedAsArray() returns an array whose keys are the hex encoded versions of the certificate serial numbers:
016d38d1fa474f65bf2c32588c82ef8c
revocationDate
reason
024f6e0301e5c803ada5526b2f4e0061
revocationDate
reason
03356327eddd1940e48cd5acd90e77ba
revocationDate
reason
0b4af0c8c5322dd1723e79d1e574ab93
revocationDate
reason
05b45ed5eb809ac598b6e5a925ed62ca
revocationDate
reason
If a serial number had multiple entries in the CRL (which shouldn't ever happen but whatever) then you'd get this:
016d38d1fa474f65bf2c32588c82ef8c
0
revocationDate
reason
1
revocationDate
reason
This structure has several advantages over ->toArray(). It's more easily serialized, you can check to see if a certificate is in the CRL by doing isset($arr[$x509['tbsCertificate']['serialNumber']]). This method is also much more performant than ->toArray() due to employing some of the lazy loading discussed in Deep Dive: ASN1\Constructed Objects: Speed and Memory Usage.
isRevoked()
This function takes one parameter - either the serial number of the certificate in question, represented by an instance of \phpseclib4\Math\BigInteger (ie. $x509['tbsCertificate']['serialNumber']), or an X509 object, from which the the serial number can be extracted.
The output of this function is a boolean. True if the certificate in question is revoked, false if it isn't.
getRevokedInfo()
This function takes one parameter - either the serial number of the certificate in question, represented by an instance of \phpseclib4\Math\BigInteger (ie. $x509['tbsCertificate']['serialNumber']), or an X509 object, from which the the serial number can be extracted. For the rest of this section this parameter shall be called the serial number.
If the certificate in question has not been revoked then null will be returned. If it has been revoked then you'll get something like this:
userCertificate
phpseclib4\File\ASN1\Types\Integer
revocationDate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
crlEntryExtensions
0
extnId
phpseclib4\File\ASN1\Types\OID
critical
phpseclib4\File\ASN1\Types\Boolean
extnValue
phpseclib4\File\ASN1\Types\Integer
userCertificate and revocationDate will always be present - crlEntryExtensions is not guaranteed to be present.
If you wanted to get the index of the revoked certificate serial number, so that you might access it directly on subsequent loads vs having to search for the serial number each time then one need simply call getRevokedIndex(), passing to it the serial number. If the index is out of bounds then null will be returned.
CRL Entry Extensions
Just as each CRL can have optional extensions, each entry in the CRL can also have extensions. RFC5280 § 5.3. CRL Entry Extensions mentions 3x extensions that could appear for each entry:
-
CRL::listValidRevocationReasons()returns an array with all the valid rejection reasons. -
The difference between the revocation date and the invalidty date is that the revocation date is when the CA actually revoked the certificate whereas the invalidity date is when the certificate (or the private key corresponding to it) was compromised. Like a compromised certificate may not be discovered immediately and even after it is discovered it may take time for the CA to actually revoke it.
listRevokedExtensions()
listRevokedExtensions() takes one parameter - either an instance of \phpseclib4\Math\BigInteger (ie. $x509['tbsCertificate']['serialNumber']) , or an X509 object, from which the the serial number can be extracted.
If the serial number does not exist in the CRL null will be returned. If the serial number does exist you'll get something like this:
0
getRevokedExtension()
getRevokedExtension() takes two parameters:
$cert, an instance of\phpseclib4\Math\BigInteger(ie.$x509['tbsCertificate']['serialNumber']) , or an X509 object, from which the the serial number can be extracted$name, the name of the extension whose contents you're trying to get
Returns an array representing the first instance of an extension even if there are multiple instances. In this array extnId is a string, critical is a boolean and extnValue is an instance of phpseclib4\File\ASN1\Types\BaseType.
If said extension or if the certificate serial number isn't present then null is returned.
Example:
$r = $crl->getRevokedExtension(
new Biginteger('016d38d1fa474f65bf2c32588c82ef8c', 16),
'id-ce-cRLReasons'
);
print_r($r);
Since id-ce-cRLReasons exists in $crl, running the above will produce an array with three elements:
extnId
phpseclib4\File\ASN1\Types\OID
extnValue
phpseclib4\File\ASN1\Types\Integer
critical
You can search by the extension name or the OID for the extension (2.5.29.21, in this case).
If you just want to see if the extension exists you could do getRevokedExtension() !== null or you could call hasRevokedExtension():
echo $crl->getRevokedExtension(
new Biginteger('016d38d1fa474f65bf2c32588c82ef8c', 16),
'id-ce-cRLReasons'
) ? 't' : 'f';
hasRevokedExtension() works largely the same way that getRevokedExtension() does, except that it returns true or false depending on if the extension exists or not.
Using CRLs in Practice
Real world CRLs can be fairly large. For example, Deep Dive: ASN1\Constructed Objects: Speed and Memory Usage discusses a 2.2mb CRL, and who wants to download 2.2mb every time you're making an AJAX request for 10 bytes of data? This is why CRLs have thisUpdate and nextUpdate as fields ($crl['tbsCertList']['thisUpdate'] and $crl['tbsCertList']['nextUpdate'], respectively).
Of course, those fields are only of use if you already have downloaded the CRL. So how do you store a CRL that's valid for ten days from the moment that you first downloaded it? That's where X509::setCRLLookupCallback() comes into play. Here's an example of its being used:
$x509 = X509::load('google.crt');
$CRLCache = [];
$cacheHits = $cacheMisses = 0;
X509::setCRLLookupCallback(function(string $url, BigInteger $serial) use (&$CRLCache, &$cacheHits, &$cacheMisses): bool {
if (isset($CRLCache[$url])) {
$cacheHits++;
} else {
$crl = CRL::load(file_get_contents($url));
$CRLCache[$url] = $crl->getRevokedAsArray();
$cacheMisses++;
}
return isset($CRLCache[$url][$serial->toHex()]);
});
echo $x509->validateNonRevokedStatus() ? 't' : 'f';
Whatever the function that's being passed to X509::setCRLLookupCallback() is, it needs to have two parameters - $url (a string) and $serial (an instance of \phpseclib4\Math\BigInteger). The output should be a boolean, true if the serial number is in the certificate, false if it isn't.
Changes you'd want to make to that function before using it in the real world:
- Update it to store stuff to and retrieve stuff from something like MySQL, MongoDB, the local filesystem, whatever.
- Check
$crl['tbsCertList']['thisUpdate']and$crl['tbsCertList']['nextUpdate']to make sure that the dates are valid. This has been omitted for brevity. - Validate the signature of the CRL. This, too, has been omitted for brevity.
- Handle the case where
file_get_contents($url)fails. Should an exception be thrown? Should it return false? Or true? That's entirely your prerogative.
Also, it should be noted that $x509->validateSignature() calls $x509->validateNonRevokedStatus(). Rather than deal with loading CAs and all that jazz, however, this section opted to call $x509->validateNonRevokedStatus() for simplicities sake.
Creating CRLs
Consider the following:
use phpseclib4\File\CRL;
$crl = new CRL();
echo $crl;
The CRL that that would produce would look something like this:
-----BEGIN X509 CRL-----
MCMwGQIBATADBgEAMAAXDTcwMDEwMTAwMDAwMFowAwYBAAMBAA==
-----END X509 CRL-----
This CRL has no extensions, does not have an issuer distinguished name, does not have a signature and it does not have any revoked serial numbers in it.
If you saved this CRL as test.pem and then did openssl crl -in test.pem -inform PEM -text -noout on that CRL you'd get this:
Certificate Revocation List (CRL):
Version 2 (0x1)
Signature Algorithm: 0.0
Issuer:
Last Update: Jan 1 00:00:00 1970 GMT
Next Update: NONE
No Revoked Certificates.
Signature Algorithm: 0.0
Signature Value:
If you did print_r($x509) on that certificate you'd get this:
tbsCertList
version
phpseclib4\File\ASN1\Types\Integer
signature
algorithm
phpseclib4\File\ASN1\Types\OID
issuer
rdnSequence
thisUpdate
utcTime
phpseclib4\File\ASN1\Types\UTCTime
signatureAlgorithm
algorithm
phpseclib4\File\ASN1\Types\OID
signature
phpseclib4\File\ASN1\Types\BitString
That said, even when doing this, $crl['tbsCertList']['thisUpdate'] will (probably) be different every time you create a new CRL. By default it's set to the current time in the systems timezone but you can change that by calling $crl->setThisDate() (or $crl->setLastDate(), which is an alias of $crl->setThisDate()).
There's also $crl['tbsCertList']['nextUpdate']. RFC5280 § 5.1.2.5. Next Update explains the purpose behind nextUpdate:
This field indicates the date by which the next CRL will be issued. The next CRL could be issued before the indicated date, but it will not be issued any later than the indicated date.
That said, RFC5280 § 5.1.2.5. Next Update is a little weird with regard to whether or not that field is required:
Conforming CRL issuers MUST include the nextUpdate field in all CRLs. Note that the ASN.1 syntax of TBSCertList describes this field as OPTIONAL, which is consistent with the ASN.1 structure defined in [X.509]. The behavior of clients processing CRLs that omit nextUpdate is not specified by this profile.
This field can be set by calling $crl->setNextDate().
Both $crl->setThisDate() and $crl->setNextDate() have one required parameter - $date - which can be either an instance of \DateTimeInterface or a string. If it's a string it'll be passed to the constructor of \DateTime and parsed by that.
Revoking Certificates
The following shows a few ways in which certificates can be revoked:
$crl->revoke($x509, 'keyCompromise', new DateTime('1970-01-01', new DateTimeZone('UTC')));
$crl->revoke($x509['tbsCertificate']['serialNumber']);
$crl->revoke(new BigInteger('deadbeef', 16), reason: 'keyCompromise');
The parameters are as follows:
-
$certCan be either an instance of
\phpseclib4\File\X509or\phpseclib4\Math\BigInteger. If it's a BigInteger it should be the serial number of the certificate in question -
$reasonCan be a string or null.
Valid reasons (from RFC5280 pp. 130) can be listed by doing
CRL::listValidRevocationReasons()but, none-the-less, the supported reasons are as follows:- unspecified
- keyCompromise
- cACompromise
- affiliationChanged
- superseded
- cessationOfOperation
- certificateHold
- removeFromCRL
- privilegeWithdrawn
- aACompromise
Reason names are case-insensitive — both
keyCompromiseandKEYCOMPROMISEare accepted. Anything not in the list throws\phpseclib4\Exception\UnexpectedValueException.Defaults to null (ie. a
id-ce-cRLReasonsCRL Entry Extension will not be present). -
$dateCan be an instance of
\DateTimeInterfaceor a string or null. If it's a string it'll be passed to the constructor of\DateTimeand parsed by that.Default to null (ie. the current date).
Certificates can be unrevoked by calling $crl->unrevoke(), which takes one parameter - $cert - an instance of \phpseclib4\File\X509 or \phpseclib4\Math\BigInteger.
Setting Extensions
CRLs have two different types of extensions that can be set - top level extensions and per-certificate extensions.
Here's an example of a top-level extension being set:
$crl->setExtension('id-ce-cRLNumber', 155);
Here's an example of a per-certificate extension being set:
$crl->setRevokedExtension($x509, 'id-ce-invalidityDate', '1970-01-01 00:00:00');
Both setExtension() and setRevokedExtension() accept an optional extra parameter - $critical, as well which, if not explicitly set, will be set to either bool(true) or bool(false) based on what RFC5280 says about it. Like some extensions are only ever supposed have critical set to either bool(false) or bool(true) and others can be set to one or the other depending on their specific situation. If you manually set an extension to bool(true) that RFC5280 says should only ever be bool(false) phpseclib will let you do so.
Setting the DN
A CRL has only has an issuer distinguished name (DN for short). The methods for manipulating that DN are as follows:
setDN()(alias:setIssuerDN())resetDN()(alias:resetIssuerDN())addDNProp()(alias:addIssuerDNProp())addDNProps()(alias:addIssuerDNProps())removeDNProps()(alias:removeIssuerDNProps())
Additionally, the issuer DN can be set by signing the CRL with a PFX. eg. $pfx->sign($x509). The Signing section elaborates.
Signing
CRLs can be signed with private key objects or PFX objects.
Here's an example of how you'd sign a CRL with a private key object:
use phpseclib4\Crypt\EC;
use phpseclib4\File\CRL;
$private = EC::createKey('nistp256');
$crl = new CRL();
// do stuff
$private->sign($crl);
Here's an example of how you'd create a CA signed cert with a PFX object that builds on the above:
use phpseclib4\File\PFX;
use phpseclib4\File\CSR;
$pfx = PFX::load('...');
$crl = new CRL();
// do stuff
$pfx->sign($crl);
This will sign the certificate and auto-set the issuer DN's to match those of the X.509 that is in the PFX.
Signing the CRL before the DNs or extensions or whatever have been set will result in the CRL having a bad signature. Like modifications done after the signature was added do not automatically result in the signature being updated to reflect those changes.
Output Format
By default, CRL objects, when cast to a string, are converted to base64-encoded PEMs. To make it so that casting to a string produces a binary encoded DERs one need simply call CRL::enableBinaryOutput(). To go back to PEMs calling CRL::disableBinaryOutput() is sufficient.
You can also convert a CRL object to binary by doing $crl->toString(['binary' => true]).