Skip to content

Commit 169d7d7

Browse files
authored
Updates for TLS: reading from encrypted PEM file & hostname fix (#742)
* tls fixes * updating test * update to support linux as well * update to support linux and windows * remove old test file * pushing minor changes
1 parent 8e7c43e commit 169d7d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+12807
-772
lines changed

cns/configuration/cns_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
"UseHTTPS" : false,
1919
"TLSSubjectName" : "",
2020
"TLSCertificatePath" : "",
21-
"TLSEndpoint" : "localhost:10091",
21+
"TLSPort" : "10091",
2222
"WireserverIP": "168.63.129.16"
2323
}

cns/configuration/configuration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type CNSConfig struct {
2323
UseHTTPS bool
2424
TLSSubjectName string
2525
TLSCertificatePath string
26-
TLSEndpoint string
26+
TLSPort string
2727
WireserverIP string
2828
}
2929

cns/service.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package cns
66
import (
77
"net/http"
88
"net/url"
9+
"strings"
910

1011
"github.com/Azure/azure-container-networking/cns/common"
1112
acn "github.com/Azure/azure-container-networking/common"
@@ -68,7 +69,12 @@ func (service *Service) Initialize(config *common.ServiceConfig) error {
6869
if err != nil {
6970
return err
7071
}
71-
if config.TlsSettings.TLSEndpoint != "" {
72+
if config.TlsSettings.TLSPort != "" {
73+
// listener.URL.Host will always be hostname:port, passed in to CNS via CNS command
74+
// else it will default to localhost
75+
// extract hostname and override tls port.
76+
hostParts := strings.Split(listener.URL.Host, ":")
77+
config.TlsSettings.TLSEndpoint = hostParts[0] + ":" + config.TlsSettings.TLSPort
7278
// Start the listener and HTTP and HTTPS server.
7379
if err = listener.StartTLS(config.ErrChan, config.TlsSettings); err != nil {
7480
return err

cns/service/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ func main() {
484484
config.TlsSettings = localtls.TlsSettings{
485485
TLSSubjectName: cnsconfig.TLSSubjectName,
486486
TLSCertificatePath: cnsconfig.TLSCertificatePath,
487-
TLSEndpoint: cnsconfig.TLSEndpoint,
487+
TLSPort: cnsconfig.TLSPort,
488488
}
489489
}
490490

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ require (
77
github.com/Masterminds/semver v1.5.0
88
github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5
99
github.com/Microsoft/hcsshim v0.8.10-0.20200506181021-222e9efadbe0
10+
github.com/billgraziano/dpapi v0.3.0
1011
github.com/containernetworking/cni v0.7.0-rc2
1112
github.com/docker/libnetwork v0.5.6
1213
github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9 // indirect
@@ -26,9 +27,9 @@ require (
2627
github.com/spf13/pflag v1.0.5
2728
github.com/spf13/viper v1.3.2
2829
go.opencensus.io v0.22.2 // indirect
29-
golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975
30+
golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975 // indirect
3031
golang.org/x/net v0.0.0-20191112182307-2180aed22343 // indirect
31-
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e
32+
golang.org/x/sys v0.0.0-20200828161417-c663848e9a16
3233
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect
3334
google.golang.org/appengine v1.6.5 // indirect
3435
k8s.io/api v0.18.2

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+Ce
4646
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
4747
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
4848
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
49+
github.com/billgraziano/dpapi v0.3.0 h1:mZ9No/GUuYpgE1X3CEFeKM2TkIPYkEluCrAALfes4Co=
50+
github.com/billgraziano/dpapi v0.3.0/go.mod h1:gi1Lin0jvovT53j0EXITkY6UPb3hTfI92POaZgj9JBA=
4951
github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
5052
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
5153
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
@@ -482,6 +484,8 @@ golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7w
482484
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
483485
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
484486
golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
487+
golang.org/x/sys v0.0.0-20200828161417-c663848e9a16 h1:54u1berWyLujz9htI1BHtZpcCEYaYNUSDFLXMNDd7To=
488+
golang.org/x/sys v0.0.0-20200828161417-c663848e9a16/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
485489
golang.org/x/sys v0.0.0-20200922070232-aee5d888a860 h1:YEu4SMq7D0cmT7CBbXfcH0NZeuChAXwsHe/9XueUO6o=
486490
golang.org/x/sys v0.0.0-20200922070232-aee5d888a860/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
487491
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

0 commit comments

Comments
 (0)