-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Specify list of ExtraSANs for the kube-apiserver certs (#263)
* Initial implementation * Remove unused field * Add tests and move long string into file * Review comments * Extend test suite * Rename test * Test Kubelet cert SAN for good measure * Remove dead code and add test for SeparateSANs * Clearer function name * Update test * Embed test CA file * Types * Change value in test * Fix types * Review comments * Revert hooks_join.go * Omit empty field * Gomega idiom * Review comments * Remove redundant length check * Review comments * Use net.ParseIP instead of string * Revert change
- Loading branch information
1 parent
9df7883
commit 15289b0
Showing
6 changed files
with
173 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIDkzCCAnugAwIBAgIUHjmfFK9cfwsJ9wVeay77DUxGfsQwDQYJKoZIhvcNAQEL | ||
BQAwWTELMAkGA1UEBhMCVVMxDjAMBgNVBAgMBVN0YXRlMQ0wCwYDVQQHDARDaXR5 | ||
MRUwEwYDVQQKDAxPcmdhbml6YXRpb24xFDASBgNVBAMMC2V4YW1wbGUuY29tMB4X | ||
DTI0MDMyMTE5MTE1NVoXDTM0MDMxOTE5MTE1NVowWTELMAkGA1UEBhMCVVMxDjAM | ||
BgNVBAgMBVN0YXRlMQ0wCwYDVQQHDARDaXR5MRUwEwYDVQQKDAxPcmdhbml6YXRp | ||
b24xFDASBgNVBAMMC2V4YW1wbGUuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A | ||
MIIBCgKCAQEAqiI/f/IWAk+2I3uxoTxB20RxrwUvPglAmsvXpkT40PbCHZ9pqI4I | ||
GQoY5mR4bQMx4s3TQNIMGIIha9IvLXVgQb6WxZNc7lLWOg/VHAw+0tUkGnO2o89v | ||
loRNJj2+ZcFu9UZQDLa/cr5pKGnFI4O3rR8DcQxt9rPtSY62ICLFwqU2Hw3fjyHI | ||
FITKmTrZNccmcWKBuOfj4DkFaFT9+jZ72W8DHBXMjAm7qZC3ar9ZlzhHT8mI942i | ||
LuNd0r47yrzga/kLCtjHDYXjBGBareIsfAZDJ+1WV9wVShL42brTwchZhBVcxY66 | ||
by8PZJPD97c22zvVyCKIUGGcFKxvWb2fBQIDAQABo1MwUTAdBgNVHQ4EFgQU3LTT | ||
fZ/8wUZhUj856yEniIkE6xwwHwYDVR0jBBgwFoAU3LTTfZ/8wUZhUj856yEniIkE | ||
6xwwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEABRNgwMKqA5Y8 | ||
7wfa+X3RsoG0BVOF/+GYCtyXBwH3lXzlOrkTbkL4e9rYGmPx67VCpsnCEAhipta3 | ||
FqjGyZFhMsaaIDlhJjm+K7MTGA7aSfo6NIBmpPRKjIQFL2rhmqs1r7riafwvvDrU | ||
CzhIi7rODCf7NAzoISU1EzowzKdKNgGYMNvIpv1pMd7p7WHQNK+W+gvQJZ93UpDY | ||
o9fgMdo44Am9bsiiPi7LAWU5qzbdUErrgFslI+inwD3dOxIwBGfEfD0ngz2nF+Jh | ||
S63GKldmH7KYVE4sdB2BvfgiraDTTHRIDNre930YIhVI+XLHIhtJ+BSpFO4w/idC | ||
xjvgVUetag== | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package utils | ||
|
||
import ( | ||
"log" | ||
"net" | ||
) | ||
|
||
// SplitIPAndDNSSANs splits a list of SANs into IP and DNS SANs | ||
// Returns a list of IP addresses and a list of DNS names | ||
func SplitIPAndDNSSANs(extraSANs []string) ([]net.IP, []string) { | ||
var ipSANs []net.IP | ||
var dnsSANs []string | ||
|
||
for _, san := range extraSANs { | ||
if san == "" { | ||
log.Println("Skipping empty SAN") | ||
continue | ||
} | ||
|
||
if ip := net.ParseIP(san); ip != nil { | ||
ipSANs = append(ipSANs, ip) | ||
} else { | ||
dnsSANs = append(dnsSANs, san) | ||
} | ||
} | ||
|
||
return ipSANs, dnsSANs | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package utils_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/canonical/k8s/pkg/utils" | ||
|
||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestSplitIPAndDNSSANs(t *testing.T) { | ||
tests := []string{"192.168.0.1", "::1", "cluster.local", "kubernetes.svc.local", "", "2001:db8:0:1:1:1:1:1"} | ||
|
||
g := NewWithT(t) | ||
gotIPs, gotDNSs := utils.SplitIPAndDNSSANs(tests) | ||
|
||
// Convert cert.IPAddresses to a slice of string representations | ||
ips := make([]string, len(gotIPs)) | ||
for i, ip := range gotIPs { | ||
ips[i] = ip.String() | ||
} | ||
|
||
g.Expect(ips).To(ConsistOf("192.168.0.1", "::1", "2001:db8:0:1:1:1:1:1")) | ||
|
||
g.Expect(gotDNSs).To(ConsistOf("cluster.local", "kubernetes.svc.local")) | ||
} |