Commit 473d34ef authored by Mike Danese's avatar Mike Danese

certs: exclude more nonsensical addresses from SANs

I noticed this when I saw 169.254.* SANs using server TLS bootstrap. This change excludes more nonsensical addresses from being requested as SANs in that flow.
parent 3cb73605
...@@ -782,7 +782,7 @@ func NewMainKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration, ...@@ -782,7 +782,7 @@ func NewMainKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
var ips []net.IP var ips []net.IP
cfgAddress := net.ParseIP(kubeCfg.Address) cfgAddress := net.ParseIP(kubeCfg.Address)
if cfgAddress == nil || cfgAddress.IsUnspecified() { if cfgAddress == nil || cfgAddress.IsUnspecified() {
localIPs, err := allLocalIPsWithoutLoopback() localIPs, err := allGlobalUnicastIPs()
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -1201,7 +1201,7 @@ type Kubelet struct { ...@@ -1201,7 +1201,7 @@ type Kubelet struct {
keepTerminatedPodVolumes bool // DEPRECATED keepTerminatedPodVolumes bool // DEPRECATED
} }
func allLocalIPsWithoutLoopback() ([]net.IP, error) { func allGlobalUnicastIPs() ([]net.IP, error) {
interfaces, err := net.Interfaces() interfaces, err := net.Interfaces()
if err != nil { if err != nil {
return nil, fmt.Errorf("could not list network interfaces: %v", err) return nil, fmt.Errorf("could not list network interfaces: %v", err)
...@@ -1215,7 +1215,7 @@ func allLocalIPsWithoutLoopback() ([]net.IP, error) { ...@@ -1215,7 +1215,7 @@ func allLocalIPsWithoutLoopback() ([]net.IP, error) {
for _, address := range addresses { for _, address := range addresses {
switch v := address.(type) { switch v := address.(type) {
case *net.IPNet: case *net.IPNet:
if !v.IP.IsLoopback() { if v.IP.IsGlobalUnicast() {
ips = append(ips, v.IP) ips = append(ips, v.IP)
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment