tls_go17.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2016-2022 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. //go:build go1.7 && !go1.8
  14. // +build go1.7,!go1.8
  15. package util
  16. import (
  17. "crypto/tls"
  18. )
  19. // CloneTLSConfig returns a copy of c. Only the exported fields are copied.
  20. // This is temporary, until this is provided by the language.
  21. // https://go-review.googlesource.com/#/c/28075/
  22. func CloneTLSConfig(c *tls.Config) *tls.Config {
  23. return &tls.Config{
  24. Rand: c.Rand,
  25. Time: c.Time,
  26. Certificates: c.Certificates,
  27. NameToCertificate: c.NameToCertificate,
  28. GetCertificate: c.GetCertificate,
  29. RootCAs: c.RootCAs,
  30. NextProtos: c.NextProtos,
  31. ServerName: c.ServerName,
  32. ClientAuth: c.ClientAuth,
  33. ClientCAs: c.ClientCAs,
  34. InsecureSkipVerify: c.InsecureSkipVerify,
  35. CipherSuites: c.CipherSuites,
  36. PreferServerCipherSuites: c.PreferServerCipherSuites,
  37. SessionTicketsDisabled: c.SessionTicketsDisabled,
  38. SessionTicketKey: c.SessionTicketKey,
  39. ClientSessionCache: c.ClientSessionCache,
  40. MinVersion: c.MinVersion,
  41. MaxVersion: c.MaxVersion,
  42. CurvePreferences: c.CurvePreferences,
  43. DynamicRecordSizingDisabled: c.DynamicRecordSizingDisabled,
  44. Renegotiation: c.Renegotiation,
  45. }
  46. }