tls_go17.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2016-2018 The NATS Authors
  2. // Licensed under the Apache License, Version 2.0 (the "License");
  3. // you may not use this file except in compliance with the License.
  4. // You may obtain a copy of the License at
  5. //
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. // +build go1.7,!go1.8
  14. package util
  15. import (
  16. "crypto/tls"
  17. )
  18. // CloneTLSConfig returns a copy of c. Only the exported fields are copied.
  19. // This is temporary, until this is provided by the language.
  20. // https://go-review.googlesource.com/#/c/28075/
  21. func CloneTLSConfig(c *tls.Config) *tls.Config {
  22. return &tls.Config{
  23. Rand: c.Rand,
  24. Time: c.Time,
  25. Certificates: c.Certificates,
  26. NameToCertificate: c.NameToCertificate,
  27. GetCertificate: c.GetCertificate,
  28. RootCAs: c.RootCAs,
  29. NextProtos: c.NextProtos,
  30. ServerName: c.ServerName,
  31. ClientAuth: c.ClientAuth,
  32. ClientCAs: c.ClientCAs,
  33. InsecureSkipVerify: c.InsecureSkipVerify,
  34. CipherSuites: c.CipherSuites,
  35. PreferServerCipherSuites: c.PreferServerCipherSuites,
  36. SessionTicketsDisabled: c.SessionTicketsDisabled,
  37. SessionTicketKey: c.SessionTicketKey,
  38. ClientSessionCache: c.ClientSessionCache,
  39. MinVersion: c.MinVersion,
  40. MaxVersion: c.MaxVersion,
  41. CurvePreferences: c.CurvePreferences,
  42. DynamicRecordSizingDisabled: c.DynamicRecordSizingDisabled,
  43. Renegotiation: c.Renegotiation,
  44. }
  45. }