Clone returns a shallow clone of c or nil if c is nil. It is safe to clone a Config that is being used concurrently by a TLS client or server.
()
| 780 | // Clone returns a shallow clone of c or nil if c is nil. It is safe to clone a Config that is |
| 781 | // being used concurrently by a TLS client or server. |
| 782 | func (c *Config) Clone() *Config { |
| 783 | if c == nil { |
| 784 | return nil |
| 785 | } |
| 786 | c.mutex.RLock() |
| 787 | defer c.mutex.RUnlock() |
| 788 | return &Config{ |
| 789 | Rand: c.Rand, |
| 790 | Time: c.Time, |
| 791 | Certificates: c.Certificates, |
| 792 | NameToCertificate: c.NameToCertificate, |
| 793 | GetCertificate: c.GetCertificate, |
| 794 | GetClientCertificate: c.GetClientCertificate, |
| 795 | GetConfigForClient: c.GetConfigForClient, |
| 796 | VerifyPeerCertificate: c.VerifyPeerCertificate, |
| 797 | VerifyConnection: c.VerifyConnection, |
| 798 | RootCAs: c.RootCAs, |
| 799 | NextProtos: c.NextProtos, |
| 800 | ServerName: c.ServerName, |
| 801 | ClientAuth: c.ClientAuth, |
| 802 | ClientCAs: c.ClientCAs, |
| 803 | InsecureSkipVerify: c.InsecureSkipVerify, |
| 804 | CipherSuites: c.CipherSuites, |
| 805 | PreferServerCipherSuites: c.PreferServerCipherSuites, |
| 806 | SessionTicketsDisabled: c.SessionTicketsDisabled, |
| 807 | SessionTicketKey: c.SessionTicketKey, |
| 808 | ClientSessionCache: c.ClientSessionCache, |
| 809 | MinVersion: c.MinVersion, |
| 810 | MaxVersion: c.MaxVersion, |
| 811 | CurvePreferences: c.CurvePreferences, |
| 812 | DynamicRecordSizingDisabled: c.DynamicRecordSizingDisabled, |
| 813 | Renegotiation: c.Renegotiation, |
| 814 | KeyLogWriter: c.KeyLogWriter, |
| 815 | sessionTicketKeys: c.sessionTicketKeys, |
| 816 | autoSessionTicketKeys: c.autoSessionTicketKeys, |
| 817 | } |
| 818 | } |
| 819 | |
| 820 | // deprecatedSessionTicketKey is set as the prefix of SessionTicketKey if it was |
| 821 | // randomized for backwards compatibility but is not in use. |