Fix #7944: Adds tls_insecure to the onvif configuration (#15603)

* Adds tls_insecure to the onvif configuration

* reformat using ruff
This commit is contained in:
Gabriel de Biasi 2024-12-19 16:54:33 -03:00 committed by GitHub
parent 4af752028f
commit ddfe8f3921
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 14 additions and 1 deletions

View File

@ -41,6 +41,7 @@ cameras:
... ...
onvif: onvif:
# Required: host of the camera being connected to. # Required: host of the camera being connected to.
# NOTE: HTTP is assumed by default; HTTPS is supported if you specify the scheme, ex: "https://0.0.0.0".
host: 0.0.0.0 host: 0.0.0.0
# Optional: ONVIF port for device (default: shown below). # Optional: ONVIF port for device (default: shown below).
port: 8000 port: 8000
@ -49,6 +50,8 @@ cameras:
user: admin user: admin
# Optional: password for login. # Optional: password for login.
password: admin password: admin
# Optional: Skip TLS verification from the ONVIF server (default: shown below)
tls_insecure: False
# Optional: PTZ camera object autotracking. Keeps a moving object in # Optional: PTZ camera object autotracking. Keeps a moving object in
# the center of the frame by automatically moving the PTZ camera. # the center of the frame by automatically moving the PTZ camera.
autotracking: autotracking:

View File

@ -686,6 +686,7 @@ cameras:
# to enable PTZ controls. # to enable PTZ controls.
onvif: onvif:
# Required: host of the camera being connected to. # Required: host of the camera being connected to.
# NOTE: HTTP is assumed by default; HTTPS is supported if you specify the scheme, ex: "https://0.0.0.0".
host: 0.0.0.0 host: 0.0.0.0
# Optional: ONVIF port for device (default: shown below). # Optional: ONVIF port for device (default: shown below).
port: 8000 port: 8000
@ -694,6 +695,8 @@ cameras:
user: admin user: admin
# Optional: password for login. # Optional: password for login.
password: admin password: admin
# Optional: Skip TLS verification from the ONVIF server (default: shown below)
tls_insecure: False
# Optional: Ignores time synchronization mismatches between the camera and the server during authentication. # Optional: Ignores time synchronization mismatches between the camera and the server during authentication.
# Using NTP on both ends is recommended and this should only be set to True in a "safe" environment due to the security risk it represents. # Using NTP on both ends is recommended and this should only be set to True in a "safe" environment due to the security risk it represents.
ignore_time_mismatch: False ignore_time_mismatch: False

View File

@ -74,6 +74,7 @@ class OnvifConfig(FrigateBaseModel):
port: int = Field(default=8000, title="Onvif Port") port: int = Field(default=8000, title="Onvif Port")
user: Optional[EnvString] = Field(default=None, title="Onvif Username") user: Optional[EnvString] = Field(default=None, title="Onvif Username")
password: Optional[EnvString] = Field(default=None, title="Onvif Password") password: Optional[EnvString] = Field(default=None, title="Onvif Password")
tls_insecure: bool = Field(default=False, title="Onvif Disable TLS verification")
autotracking: PtzAutotrackConfig = Field( autotracking: PtzAutotrackConfig = Field(
default_factory=PtzAutotrackConfig, default_factory=PtzAutotrackConfig,
title="PTZ auto tracking config.", title="PTZ auto tracking config.",

View File

@ -6,6 +6,7 @@ from importlib.util import find_spec
from pathlib import Path from pathlib import Path
import numpy import numpy
import requests
from onvif import ONVIFCamera, ONVIFError from onvif import ONVIFCamera, ONVIFError
from zeep.exceptions import Fault, TransportError from zeep.exceptions import Fault, TransportError
from zeep.transports import Transport from zeep.transports import Transport
@ -48,7 +49,11 @@ class OnvifController:
if cam.onvif.host: if cam.onvif.host:
try: try:
transport = Transport(timeout=10, operation_timeout=10) session = requests.Session()
session.verify = not cam.onvif.tls_insecure
transport = Transport(
timeout=10, operation_timeout=10, session=session
)
self.cams[cam_name] = { self.cams[cam_name] = {
"onvif": ONVIFCamera( "onvif": ONVIFCamera(
cam.onvif.host, cam.onvif.host,

View File

@ -142,6 +142,7 @@ export interface CameraConfig {
password: string | null; password: string | null;
port: number; port: number;
user: string | null; user: string | null;
tls_insecure: boolean;
}; };
record: { record: {
enabled: boolean; enabled: boolean;