fiorix / go-diameter

Diameter stack and Base Protocol (RFC 6733) for the Go programming language
Other
244 stars 141 forks source link

Clients cannot verify server certificates when connecting #198

Open wkral-netlync opened 2 months ago

wkral-netlync commented 2 months ago

Currently, there is no public interface to supply TLSConfig to the srv *Server argument of dialTLS. There is only one caller of dialTLS: DialTLSExt which constructs a Server without TLSConfig just prior to calling dialTLS.

So in dialTLS srv.TLSConfig is always nil in the following: https://github.com/fiorix/go-diameter/blob/f6f13778dcc4d7d18197f76eab5252de712f3ba6/diam/client.go#L135-L139

Therefore InsecureSkipVerify will always be true in the TLSConfig used by the client. It's an understandable default since ServerName must be part of the config if InsecureSkipVerify is false, according to: https://pkg.go.dev/crypto/tls#Client. Just there isn't a way to get to the other branch of that if. All the customization from supplying a TLSConfig such as using a different cert bundle than the system level certs are also not accessible.

Perhaps another DialTLS variant could be added to supply the TLSConfig? I expect the existing interfaces probably shouldn't change as there are likely many uses of them.