rtsp source: set ServerName when using TLS (#708)

This commit is contained in:
aler9
2021-12-03 23:15:21 +01:00
parent 0d8f14388e
commit a1fed6fb38
5 changed files with 42 additions and 30 deletions

View File

@@ -120,21 +120,24 @@ func (s *rtspSource) run() {
func (s *rtspSource) runInner() bool {
s.log(logger.Debug, "connecting")
tlsConfig := &tls.Config{}
var tlsConfig *tls.Config
if s.fingerprint != "" {
tlsConfig.InsecureSkipVerify = true
tlsConfig.VerifyConnection = func(cs tls.ConnectionState) error {
h := sha256.New()
h.Write(cs.PeerCertificates[0].Raw)
hstr := hex.EncodeToString(h.Sum(nil))
fingerprintLower := strings.ToLower(s.fingerprint)
tlsConfig = &tls.Config{
InsecureSkipVerify: true,
VerifyConnection: func(cs tls.ConnectionState) error {
h := sha256.New()
h.Write(cs.PeerCertificates[0].Raw)
hstr := hex.EncodeToString(h.Sum(nil))
fingerprintLower := strings.ToLower(s.fingerprint)
if hstr != fingerprintLower {
return fmt.Errorf("server fingerprint do not match: expected %s, got %s",
fingerprintLower, hstr)
}
if hstr != fingerprintLower {
return fmt.Errorf("server fingerprint do not match: expected %s, got %s",
fingerprintLower, hstr)
}
return nil
return nil
},
}
}