Use inclusive terminology for cert blocking (#272)

This commit is contained in:
forfuncsake 2020-08-06 11:17:47 +10:00 committed by GitHub
parent ac557f381b
commit 25964b54f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 23 deletions

12
cert.go
View File

@ -149,10 +149,16 @@ func loadCAFromConfig(c *Config) (*cert.NebulaCAPool, error) {
return nil, fmt.Errorf("error while adding CA certificate to CA trust store: %s", err) return nil, fmt.Errorf("error while adding CA certificate to CA trust store: %s", err)
} }
// pki.blacklist entered the scene at about the same time we aliased x509 to pki, not supporting backwards compat for _, fp := range c.GetStringSlice("pki.blocklist", []string{}) {
l.WithField("fingerprint", fp).Infof("Blocklisting cert")
CAs.BlocklistFingerprint(fp)
}
// Support deprecated config for at leaast one minor release to allow for migrations
for _, fp := range c.GetStringSlice("pki.blacklist", []string{}) { for _, fp := range c.GetStringSlice("pki.blacklist", []string{}) {
l.WithField("fingerprint", fp).Infof("Blacklisting cert") l.WithField("fingerprint", fp).Infof("Blocklisting cert")
CAs.BlacklistFingerprint(fp) l.Warn("pki.blacklist is deprecated and will not be supported in a future release. Please migrate your config to use pki.blocklist")
CAs.BlocklistFingerprint(fp)
} }
return CAs, nil return CAs, nil

View File

@ -8,14 +8,14 @@ import (
type NebulaCAPool struct { type NebulaCAPool struct {
CAs map[string]*NebulaCertificate CAs map[string]*NebulaCertificate
certBlacklist map[string]struct{} certBlocklist map[string]struct{}
} }
// NewCAPool creates a CAPool // NewCAPool creates a CAPool
func NewCAPool() *NebulaCAPool { func NewCAPool() *NebulaCAPool {
ca := NebulaCAPool{ ca := NebulaCAPool{
CAs: make(map[string]*NebulaCertificate), CAs: make(map[string]*NebulaCertificate),
certBlacklist: make(map[string]struct{}), certBlocklist: make(map[string]struct{}),
} }
return &ca return &ca
@ -67,24 +67,24 @@ func (ncp *NebulaCAPool) AddCACertificate(pemBytes []byte) ([]byte, error) {
return pemBytes, nil return pemBytes, nil
} }
// BlacklistFingerprint adds a cert fingerprint to the blacklist // BlocklistFingerprint adds a cert fingerprint to the blocklist
func (ncp *NebulaCAPool) BlacklistFingerprint(f string) { func (ncp *NebulaCAPool) BlocklistFingerprint(f string) {
ncp.certBlacklist[f] = struct{}{} ncp.certBlocklist[f] = struct{}{}
} }
// ResetCertBlacklist removes all previously blacklisted cert fingerprints // ResetCertBlocklist removes all previously blocklisted cert fingerprints
func (ncp *NebulaCAPool) ResetCertBlacklist() { func (ncp *NebulaCAPool) ResetCertBlocklist() {
ncp.certBlacklist = make(map[string]struct{}) ncp.certBlocklist = make(map[string]struct{})
} }
// IsBlacklisted returns true if the fingerprint fails to generate or has been explicitly blacklisted // IsBlocklisted returns true if the fingerprint fails to generate or has been explicitly blocklisted
func (ncp *NebulaCAPool) IsBlacklisted(c *NebulaCertificate) bool { func (ncp *NebulaCAPool) IsBlocklisted(c *NebulaCertificate) bool {
h, err := c.Sha256Sum() h, err := c.Sha256Sum()
if err != nil { if err != nil {
return true return true
} }
if _, ok := ncp.certBlacklist[h]; ok { if _, ok := ncp.certBlocklist[h]; ok {
return true return true
} }

View File

@ -244,10 +244,10 @@ func (nc *NebulaCertificate) Expired(t time.Time) bool {
return nc.Details.NotBefore.After(t) || nc.Details.NotAfter.Before(t) return nc.Details.NotBefore.After(t) || nc.Details.NotAfter.Before(t)
} }
// Verify will ensure a certificate is good in all respects (expiry, group membership, signature, cert blacklist, etc) // Verify will ensure a certificate is good in all respects (expiry, group membership, signature, cert blocklist, etc)
func (nc *NebulaCertificate) Verify(t time.Time, ncp *NebulaCAPool) (bool, error) { func (nc *NebulaCertificate) Verify(t time.Time, ncp *NebulaCAPool) (bool, error) {
if ncp.IsBlacklisted(nc) { if ncp.IsBlocklisted(nc) {
return false, fmt.Errorf("certificate has been blacklisted") return false, fmt.Errorf("certificate has been blocked")
} }
signer, err := ncp.GetCAForCert(nc) signer, err := ncp.GetCAForCert(nc)

View File

@ -172,13 +172,13 @@ func TestNebulaCertificate_Verify(t *testing.T) {
f, err := c.Sha256Sum() f, err := c.Sha256Sum()
assert.Nil(t, err) assert.Nil(t, err)
caPool.BlacklistFingerprint(f) caPool.BlocklistFingerprint(f)
v, err := c.Verify(time.Now(), caPool) v, err := c.Verify(time.Now(), caPool)
assert.False(t, v) assert.False(t, v)
assert.EqualError(t, err, "certificate has been blacklisted") assert.EqualError(t, err, "certificate has been blocked")
caPool.ResetCertBlacklist() caPool.ResetCertBlocklist()
v, err = c.Verify(time.Now(), caPool) v, err = c.Verify(time.Now(), caPool)
assert.True(t, v) assert.True(t, v)
assert.Nil(t, err) assert.Nil(t, err)

View File

@ -7,8 +7,8 @@ pki:
ca: /etc/nebula/ca.crt ca: /etc/nebula/ca.crt
cert: /etc/nebula/host.crt cert: /etc/nebula/host.crt
key: /etc/nebula/host.key key: /etc/nebula/host.key
#blacklist is a list of certificate fingerprints that we will refuse to talk to #blocklist is a list of certificate fingerprints that we will refuse to talk to
#blacklist: #blocklist:
# - c99d4e650533b92061b09918e838a5a0a6aaee21eed1d12fd937682865936c72 # - c99d4e650533b92061b09918e838a5a0a6aaee21eed1d12fd937682865936c72
# The static host map defines a set of hosts with fixed IP addresses on the internet (or any network). # The static host map defines a set of hosts with fixed IP addresses on the internet (or any network).
@ -64,7 +64,7 @@ lighthouse:
# the inverse). CIDR rules are matched after interface name rules. # the inverse). CIDR rules are matched after interface name rules.
# Default is all local IP addresses. # Default is all local IP addresses.
#local_allow_list: #local_allow_list:
# Example to blacklist tun0 and all docker interfaces. # Example to block tun0 and all docker interfaces.
#interfaces: #interfaces:
#tun0: false #tun0: false
#'docker.*': false #'docker.*': false