Skip to content
This repository has been archived by the owner on Dec 21, 2019. It is now read-only.

Commit

Permalink
fixes #204 macat: tcp+tls complains about missing TLS configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit Renker authored and Gerrit Renker committed May 25, 2016
1 parent dd21726 commit 83e303c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 8 additions & 4 deletions macat/macat.go
Expand Up @@ -553,8 +553,6 @@ func main() {
fatalf("Protocol not specified.")
}

sock.SetOption(mangos.OptionTLSConfig, &tlscfg)

if len(listenAddrs) == 0 && len(dialAddrs) == 0 {
fatalf("No address specified.")
}
Expand All @@ -581,6 +579,8 @@ func main() {
}

for i := range listenAddrs {
var opts = make(map[string]interface{})

// TLS addresses require a certificate to be supplied.
if strings.HasPrefix(listenAddrs[i], "tls") {
if len(tlscfg.Certificates) == 0 {
Expand All @@ -589,20 +589,24 @@ func main() {
if tlscfg.InsecureSkipVerify && !noVerifyTLS {
fatalf("No CA certificate specified.")
}
opts[mangos.OptionTLSConfig] = &tlscfg
}
err := sock.Listen(listenAddrs[i])
err := sock.ListenOptions(listenAddrs[i], opts)
if err != nil {
fatalf("Bind(%s): %v", listenAddrs[i], err)
}
}

for i := range dialAddrs {
var opts = make(map[string]interface{})

if strings.HasPrefix(dialAddrs[i], "tls") {
if tlscfg.InsecureSkipVerify && !noVerifyTLS {
fatalf("No CA certificate specified.")
}
opts[mangos.OptionTLSConfig] = &tlscfg
}
err := sock.Dial(dialAddrs[i])
err := sock.DialOptions(dialAddrs[i], opts)
if err != nil {
fatalf("Dial(%s): %v", dialAddrs[i], err)
}
Expand Down
3 changes: 2 additions & 1 deletion options.go
Expand Up @@ -74,7 +74,8 @@ const (
// indicate an infinite time. Default is 1 second.
OptionSurveyTime = "SURVEY-TIME"

// OptionTLSConfig is used to supply TLS configuration details.
// OptionTLSConfig is used to supply TLS configuration details. It
// can be set using the ListenOptions or DialOptions.
// The parameter is a tls.Config pointer.
OptionTLSConfig = "TLS-CONFIG"

Expand Down

0 comments on commit 83e303c

Please sign in to comment.