Add mutex locking to SetTLSConfig

This change ensures that the SetTLSConfig method is thread-safe by adding a mutex lock. The lock is acquired before any changes to the TLS configuration and released afterward to prevent concurrent access issues.
This commit is contained in:
Winni Neessen 2024-09-27 11:58:08 +02:00
parent 2234f0c5bc
commit f59aa23ed8
Signed by: wneessen
GPG key ID: 385AC9889632126E

View file

@ -555,6 +555,9 @@ func (c *Client) SetLogger(logger log.Logger) {
// SetTLSConfig overrides the current *tls.Config with the given *tls.Config value
func (c *Client) SetTLSConfig(tlsconfig *tls.Config) error {
c.mutex.Lock()
defer c.mutex.Unlock()
if tlsconfig == nil {
return ErrInvalidTLSConfig
}