diff --git a/cache.go b/cache.go index fb41de3..8ce4014 100644 --- a/cache.go +++ b/cache.go @@ -199,9 +199,13 @@ func (c *Cache) Map() map[string]CacheObject { } type CacheObject struct { - Subject pkix.Name - NotAfter time.Time - Paths []PathObject + Paths []PathObject + Subject pkix.Name + BasicConstraintsValid bool + DNSNames []string + IPAddresses []string + NotAfter time.Time + NotBefore time.Time } type PathObject struct { diff --git a/client.go b/client.go index 9f39388..c5ee62a 100644 --- a/client.go +++ b/client.go @@ -101,9 +101,13 @@ func (c *Client) UserpassAuth(username, password string) error { } type CacheItem struct { - Paths []CacheItemPath `json:"paths"` - CommonName string `json:"common_name"` - NotAfter int64 `json:"not_after"` + Paths []CacheItemPath `json:"paths"` + CommonName string `json:"common_name"` + BasicConstraintsValid bool `json:"basic_constraints_valid"` + DNSNames []string `json:"dns_names"` + IPAddresses []string `json:"ip_addresses"` + NotAfter int64 `json:"not_after"` + NotBefore int64 `json:"not_before"` } type CacheItemPath struct { diff --git a/core.go b/core.go index eb06156..b8523b9 100644 --- a/core.go +++ b/core.go @@ -5,6 +5,7 @@ import ( "crypto/x509" "encoding/pem" "fmt" + "net" "runtime" "sync" @@ -89,14 +90,18 @@ func (b *Core) populateUsing(cache *Cache, paths storage.PathList) (*PopulateSta cache.Merge( fmt.Sprintf("%s", sha1.Sum(cert.Raw)), CacheObject{ - Subject: cert.Subject, - NotAfter: cert.NotAfter, Paths: []PathObject{ { Location: path + ":" + k, Source: b.Name, }, }, + Subject: cert.Subject, + BasicConstraintsValid: cert.BasicConstraintsValid, + DNSNames: cert.DNSNames, + IPAddresses: parseIPs(cert.IPAddresses), + NotAfter: cert.NotAfter, + NotBefore: cert.NotBefore, }, ) } @@ -152,3 +157,15 @@ func parseCert(c string) []*x509.Certificate { return certs } + +func parseIPs(ips []net.IP) []string { + if ips == nil { + return nil + } + + out := []string{} + for _, ip := range ips { + out = append(out, ip.String()) + } + return out +} diff --git a/server/manager/source_manager.go b/server/manager/source_manager.go index 02ff923..dcac62d 100644 --- a/server/manager/source_manager.go +++ b/server/manager/source_manager.go @@ -122,9 +122,13 @@ func (s *SourceManager) Data() doomsday.CacheItems { }) } items = append(items, doomsday.CacheItem{ - Paths: paths, - CommonName: v.Subject.CommonName, - NotAfter: v.NotAfter.Unix(), + Paths: paths, + CommonName: v.Subject.CommonName, + BasicConstraintsValid: v.BasicConstraintsValid, + DNSNames: v.DNSNames, + IPAddresses: v.IPAddresses, + NotAfter: v.NotAfter.Unix(), + NotBefore: v.NotBefore.Unix(), }) }