@@ -4,6 +4,7 @@ package umbilical
44
55import (
66 "github.com/bwesterb/mtc"
7+ "github.com/bwesterb/mtc/umbilical/revocation"
78
89 "bytes"
910 "crypto/tls"
@@ -96,12 +97,13 @@ func GetChainFromTLSServer(addr string) (chain []*x509.Certificate, err error) {
9697// Also we require basically the same chain to be valid for the full
9798// duration of the assertion.
9899//
100+ // If rc is set, checks whether the certificate is revoked. Does not check
101+ // revocation of intermediates.
102+ //
99103// If consistent, returns one or more verified chains. This is useful
100104// for revocation checks.
101- //
102- // Note: does not perform any revocation check. Also does not check SCTs.
103105func CheckAssertionValidForX509 (a mtc.Assertion , batch mtc.Batch ,
104- chain []* x509.Certificate , roots * x509.CertPool ) (
106+ chain []* x509.Certificate , roots * x509.CertPool , rc * revocation. Checker ) (
105107 [][]* x509.Certificate , error ) {
106108 if len (chain ) == 0 {
107109 return nil , errors .New ("empty chain" )
@@ -212,5 +214,16 @@ func CheckAssertionValidForX509(a mtc.Assertion, batch mtc.Batch,
212214 )
213215 }
214216
217+ if rc != nil {
218+ revoked , err := rc .Revoked (ret [0 ][0 ], ret [0 ][1 ])
219+ if err != nil {
220+ return nil , fmt .Errorf ("checking revocation: %w" , err )
221+ }
222+
223+ if revoked {
224+ return nil , errors .New ("certificate is revoked" )
225+ }
226+ }
227+
215228 return ret , nil
216229}
0 commit comments