Skip to content

Commit

Permalink
Add ability to set whitelist in config.json
Browse files Browse the repository at this point in the history
  • Loading branch information
grittygrease committed Jun 25, 2015
1 parent 6d6d1ad commit a42b0f1
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,20 @@ type CertificatePolicy struct {
// A SigningProfile stores information that the CA needs to store
// signature policy.
type SigningProfile struct {
Usage []string `json:"usages"`
IssuerURL []string `json:"issuer_urls"`
OCSP string `json:"ocsp_url"`
CRL string `json:"crl_url"`
CA bool `json:"is_ca"`
OCSPNoCheck bool `json:"ocsp_no_check"`
ExpiryString string `json:"expiry"`
BackdateString string `json:"backdate"`
AuthKeyName string `json:"auth_key"`
RemoteName string `json:"remote"`
NotBefore time.Time `json:"not_before"`
NotAfter time.Time `json:"not_after"`
Usage []string `json:"usages"`
IssuerURL []string `json:"issuer_urls"`
OCSP string `json:"ocsp_url"`
CRL string `json:"crl_url"`
CA bool `json:"is_ca"`
PolicyStrings []string `json:"policies"`
OCSPNoCheck bool `json:"ocsp_no_check"`
ExpiryString string `json:"expiry"`
BackdateString string `json:"backdate"`
AuthKeyName string `json:"auth_key"`
RemoteName string `json:"remote"`
NotBefore time.Time `json:"not_before"`
NotAfter time.Time `json:"not_after"`
NameWhitelistString string `json:"name_whitelist"`

Policies []asn1.ObjectIdentifier
Expiry time.Duration
Expand Down Expand Up @@ -201,6 +203,16 @@ func (p *SigningProfile) populate(cfg *Config) error {
}
}

if p.NameWhitelistString != "" {
log.Debug("compiling whitelist regular expression")
rule, err := regexp.Compile(p.NameWhitelistString)
if err != nil {
return cferr.Wrap(cferr.PolicyError, cferr.InvalidPolicy,
errors.New("failed to compile name whitelist section"))
}
p.NameWhitelist = rule
}

return nil
}

Expand Down

0 comments on commit a42b0f1

Please sign in to comment.