Browse code

client: transport: fix tlsconfig Clone() on different Golang versions

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>

Akihiro Suda authored on 2016/09/08 13:38:55
Showing 3 changed files
... ...
@@ -1,4 +1,4 @@
1
-// +build !go1.7,!windows
1
+// +build go1.8
2 2
 
3 3
 package transport
4 4
 
5 5
new file mode 100644
... ...
@@ -0,0 +1,31 @@
0
+// +build go1.6,!go1.7
1
+
2
+package transport
3
+
4
+import "crypto/tls"
5
+
6
+// TLSConfigClone returns a clone of tls.Config. This function is provided for
7
+// compatibility for go1.6 that doesn't include this method in stdlib.
8
+func TLSConfigClone(c *tls.Config) *tls.Config {
9
+	return &tls.Config{
10
+		Rand:                     c.Rand,
11
+		Time:                     c.Time,
12
+		Certificates:             c.Certificates,
13
+		NameToCertificate:        c.NameToCertificate,
14
+		GetCertificate:           c.GetCertificate,
15
+		RootCAs:                  c.RootCAs,
16
+		NextProtos:               c.NextProtos,
17
+		ServerName:               c.ServerName,
18
+		ClientAuth:               c.ClientAuth,
19
+		ClientCAs:                c.ClientCAs,
20
+		InsecureSkipVerify:       c.InsecureSkipVerify,
21
+		CipherSuites:             c.CipherSuites,
22
+		PreferServerCipherSuites: c.PreferServerCipherSuites,
23
+		SessionTicketsDisabled:   c.SessionTicketsDisabled,
24
+		SessionTicketKey:         c.SessionTicketKey,
25
+		ClientSessionCache:       c.ClientSessionCache,
26
+		MinVersion:               c.MinVersion,
27
+		MaxVersion:               c.MaxVersion,
28
+		CurvePreferences:         c.CurvePreferences,
29
+	}
30
+}
... ...
@@ -1,4 +1,4 @@
1
-// +build go1.7
1
+// +build go1.7,!go1.8
2 2
 
3 3
 package transport
4 4