blob: babb007fb4144ac456faeb685e24b62186c7c517 [file] [log] [blame]
khenaidooffe076b2019-01-15 16:08:08 -05001// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// +build !go1.8
6
7package websocket
8
9import "crypto/tls"
10
11// cloneTLSConfig clones all public fields except the fields
12// SessionTicketsDisabled and SessionTicketKey. This avoids copying the
13// sync.Mutex in the sync.Once and makes it safe to call cloneTLSConfig on a
14// config in active use.
15func cloneTLSConfig(cfg *tls.Config) *tls.Config {
16 if cfg == nil {
17 return &tls.Config{}
18 }
19 return &tls.Config{
20 Rand: cfg.Rand,
21 Time: cfg.Time,
22 Certificates: cfg.Certificates,
23 NameToCertificate: cfg.NameToCertificate,
24 GetCertificate: cfg.GetCertificate,
25 RootCAs: cfg.RootCAs,
26 NextProtos: cfg.NextProtos,
27 ServerName: cfg.ServerName,
28 ClientAuth: cfg.ClientAuth,
29 ClientCAs: cfg.ClientCAs,
30 InsecureSkipVerify: cfg.InsecureSkipVerify,
31 CipherSuites: cfg.CipherSuites,
32 PreferServerCipherSuites: cfg.PreferServerCipherSuites,
33 ClientSessionCache: cfg.ClientSessionCache,
34 MinVersion: cfg.MinVersion,
35 MaxVersion: cfg.MaxVersion,
36 CurvePreferences: cfg.CurvePreferences,
37 }
38}