mirror of
https://github.com/aler9/rtsp-simple-server
synced 2025-10-07 16:41:13 +08:00
make sourceFingerprint optional and allow standard certificate validation
This commit is contained in:
@@ -117,24 +117,28 @@ func (s *rtspSource) run() {
|
||||
func (s *rtspSource) runInner() bool {
|
||||
s.log(logger.Debug, "connecting")
|
||||
|
||||
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)
|
||||
|
||||
if hstr != fingerprintLower {
|
||||
return fmt.Errorf("server fingerprint do not match: expected %s, got %s",
|
||||
fingerprintLower, hstr)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
client := &gortsplib.Client{
|
||||
Transport: s.proto.Transport,
|
||||
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)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
},
|
||||
Transport: s.proto.Transport,
|
||||
TLSConfig: tlsConfig,
|
||||
ReadTimeout: time.Duration(s.readTimeout),
|
||||
WriteTimeout: time.Duration(s.writeTimeout),
|
||||
ReadBufferCount: s.readBufferCount,
|
||||
|
Reference in New Issue
Block a user