Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TLS cipher suite options and CA path support #2963

Merged
merged 3 commits into from
Apr 27, 2017
Merged

Conversation

kyhavlov
Copy link
Contributor

Resolves #2959

@@ -17,6 +17,7 @@ import (
"github.com/hashicorp/consul/types"
"github.com/hashicorp/consul/watch"
"github.com/mitchellh/mapstructure"
"github.com/hashicorp/consul/tlsutil"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use goimports for sorting imports correctly

@@ -13,6 +13,7 @@ import (
"time"

"github.com/hashicorp/consul/lib"
"crypto/tls"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import sorting

}

return suites, nil
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gofmt this file

@@ -9,6 +9,7 @@ import (
"testing"

"github.com/hashicorp/yamux"
"reflect"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imports

@@ -494,3 +509,26 @@ func TestConfig_IncomingTLS_TLSMinVersion(t *testing.T) {
}
}
}

func TestConfig_ParseCiphers(t *testing.T) {
testOk := "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_GCM_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_256_GCM_SHA384"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to join a []string{...} to keep it readable

if err != nil {
t.Fatal(err)
}
if len(v) != 12 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you compare the values instead of the lengths you get a more robust test.

ciphers := []uint16{...}
if got, want := v, ciphers; !reflect.DeepEqual(got, want) {
    t.Fatalf("got ciphers %#v want %#v", got, want)
}

t.Fatal("should fail on unsupported cipherX")
}

testOrder := "TLS_RSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_128_GCM_SHA256"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test becomes redundant if you do the other test.

Copy link
Contributor

@magiconair magiconair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once you remove the extra blank line.

@@ -12,8 +12,8 @@ import (
"testing"
"time"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove blank line and goimports

@magiconair
Copy link
Contributor

LGTM. Please squash and merge :)

@magiconair magiconair merged commit b70e419 into master Apr 27, 2017
@magiconair
Copy link
Contributor

Just realized that I could also do this myself.

@kyhavlov kyhavlov deleted the tls-improvements branch April 27, 2017 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants