From ee09ac3b6ce4956b70b445bedd5eceb7c2ed2146 Mon Sep 17 00:00:00 2001 From: Johan Brandhorst Date: Fri, 15 Dec 2017 19:04:34 +0000 Subject: [PATCH 1/2] Rename tls.go to tls_go17.go, delete unsupported file --- util/{tls.go => tls_go17.go} | 0 util/tls_pre17.go | 35 ----------------------------------- 2 files changed, 35 deletions(-) rename util/{tls.go => tls_go17.go} (100%) delete mode 100644 util/tls_pre17.go diff --git a/util/tls.go b/util/tls_go17.go similarity index 100% rename from util/tls.go rename to util/tls_go17.go diff --git a/util/tls_pre17.go b/util/tls_pre17.go deleted file mode 100644 index db198ae31..000000000 --- a/util/tls_pre17.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2016 Apcera Inc. All rights reserved. -// +build go1.5,!go1.7 - -package util - -import ( - "crypto/tls" -) - -// CloneTLSConfig returns a copy of c. Only the exported fields are copied. -// This is temporary, until this is provided by the language. -// https://go-review.googlesource.com/#/c/28075/ -func CloneTLSConfig(c *tls.Config) *tls.Config { - return &tls.Config{ - Rand: c.Rand, - Time: c.Time, - Certificates: c.Certificates, - NameToCertificate: c.NameToCertificate, - GetCertificate: c.GetCertificate, - RootCAs: c.RootCAs, - NextProtos: c.NextProtos, - ServerName: c.ServerName, - ClientAuth: c.ClientAuth, - ClientCAs: c.ClientCAs, - InsecureSkipVerify: c.InsecureSkipVerify, - CipherSuites: c.CipherSuites, - PreferServerCipherSuites: c.PreferServerCipherSuites, - SessionTicketsDisabled: c.SessionTicketsDisabled, - SessionTicketKey: c.SessionTicketKey, - ClientSessionCache: c.ClientSessionCache, - MinVersion: c.MinVersion, - MaxVersion: c.MaxVersion, - CurvePreferences: c.CurvePreferences, - } -} From 4798ae8e42039c09f0e56184984a99bd5ca33585 Mon Sep 17 00:00:00 2001 From: Johan Brandhorst Date: Fri, 15 Dec 2017 19:04:49 +0000 Subject: [PATCH 2/2] Add tls.go for Go 1.8. Fixes #335 --- util/tls.go | 15 +++++++++++++++ util/tls_go17.go | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 util/tls.go diff --git a/util/tls.go b/util/tls.go new file mode 100644 index 000000000..15bed9b1e --- /dev/null +++ b/util/tls.go @@ -0,0 +1,15 @@ +// Copyright 2017 Apcera Inc. All rights reserved. +// +build go1.8 + +package util + +import "crypto/tls" + +// CloneTLSConfig returns a copy of c. +func CloneTLSConfig(c *tls.Config) *tls.Config { + if c == nil { + return &tls.Config{} + } + + return c.Clone() +} diff --git a/util/tls_go17.go b/util/tls_go17.go index 51da0b88c..3e38fc4d1 100644 --- a/util/tls_go17.go +++ b/util/tls_go17.go @@ -1,5 +1,5 @@ // Copyright 2016 Apcera Inc. All rights reserved. -// +build go1.7 +// +build go1.7,!go1.8 package util