1
0

client_clone_legacy.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // 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. // +build !go1.8
  5. package websocket
  6. import "crypto/tls"
  7. // cloneTLSConfig clones all public fields except the fields
  8. // SessionTicketsDisabled and SessionTicketKey. This avoids copying the
  9. // sync.Mutex in the sync.Once and makes it safe to call cloneTLSConfig on a
  10. // config in active use.
  11. func cloneTLSConfig(cfg *tls.Config) *tls.Config {
  12. if cfg == nil {
  13. return &tls.Config{}
  14. }
  15. return &tls.Config{
  16. Rand: cfg.Rand,
  17. Time: cfg.Time,
  18. Certificates: cfg.Certificates,
  19. NameToCertificate: cfg.NameToCertificate,
  20. GetCertificate: cfg.GetCertificate,
  21. RootCAs: cfg.RootCAs,
  22. NextProtos: cfg.NextProtos,
  23. ServerName: cfg.ServerName,
  24. ClientAuth: cfg.ClientAuth,
  25. ClientCAs: cfg.ClientCAs,
  26. InsecureSkipVerify: cfg.InsecureSkipVerify,
  27. CipherSuites: cfg.CipherSuites,
  28. PreferServerCipherSuites: cfg.PreferServerCipherSuites,
  29. ClientSessionCache: cfg.ClientSessionCache,
  30. MinVersion: cfg.MinVersion,
  31. MaxVersion: cfg.MaxVersion,
  32. CurvePreferences: cfg.CurvePreferences,
  33. }
  34. }