Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added more cert information fields #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 7 additions & 3 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
21 changes: 19 additions & 2 deletions core.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/x509"
"encoding/pem"
"fmt"
"net"
"runtime"
"sync"

Expand Down Expand Up @@ -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,
},
)
}
Expand Down Expand Up @@ -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
}
10 changes: 7 additions & 3 deletions server/manager/source_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
})
}

Expand Down