Skip to content

Commit c68df53

Browse files
committed
Default to validating bundles with x509.ExtKeyUsageAny
As of Go 1.10 Certificate.Verify will check the allowed key usages for the entire chain: https://golang.org/doc/go1.10#crypto/x509
1 parent e9bb1b2 commit c68df53

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

bundler/bundler.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,15 @@ type options struct {
7272

7373
var defaultOptions = options{
7474
keyUsages: []x509.ExtKeyUsage{
75-
x509.ExtKeyUsageServerAuth,
76-
x509.ExtKeyUsageClientAuth,
77-
x509.ExtKeyUsageMicrosoftServerGatedCrypto,
78-
x509.ExtKeyUsageNetscapeServerGatedCrypto,
75+
x509.ExtKeyUsageAny,
7976
},
8077
}
8178

8279
// An Option sets options such as allowed key usages, etc.
8380
type Option func(*options)
8481

85-
// WithKeyUsages lets you set which Extended Key Usage values are acceptable.
82+
// WithKeyUsages lets you set which Extended Key Usage values are acceptable. By
83+
// default x509.ExtKeyUsageAny will be used.
8684
func WithKeyUsages(usages ...x509.ExtKeyUsage) Option {
8785
return func(o *options) {
8886
o.keyUsages = usages

bundler/bundler_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -912,11 +912,7 @@ func TestBundlerWithEmptyRootInfo(t *testing.T) {
912912
}
913913

914914
func TestBundlerClientAuth(t *testing.T) {
915-
b, err := NewBundler(
916-
"testdata/client-auth/root.pem",
917-
"testdata/client-auth/int.pem",
918-
WithKeyUsages(x509.ExtKeyUsageClientAuth),
919-
)
915+
b, err := NewBundler("testdata/client-auth/root.pem", "testdata/client-auth/int.pem")
920916
if err != nil {
921917
t.Fatal(err)
922918
}

0 commit comments

Comments
 (0)