Skip to content

Commit

Permalink
Fix #7944: Adds tls_insecure to the onvif configuration (#15603)
Browse files Browse the repository at this point in the history
* Adds tls_insecure to the onvif configuration

* reformat using ruff
  • Loading branch information
gabrielbiasi authored Dec 19, 2024
1 parent 4af7520 commit ddfe8f3
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/docs/configuration/autotracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ cameras:
...
onvif:
# 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
# Optional: ONVIF port for device (default: shown below).
port: 8000
Expand All @@ -49,6 +50,8 @@ cameras:
user: admin
# Optional: password for login.
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
# the center of the frame by automatically moving the PTZ camera.
autotracking:
Expand Down
3 changes: 3 additions & 0 deletions docs/docs/configuration/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,7 @@ cameras:
# to enable PTZ controls.
onvif:
# 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
# Optional: ONVIF port for device (default: shown below).
port: 8000
Expand All @@ -694,6 +695,8 @@ cameras:
user: admin
# Optional: password for login.
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.
# 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
Expand Down
1 change: 1 addition & 0 deletions frigate/config/camera/onvif.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class OnvifConfig(FrigateBaseModel):
port: int = Field(default=8000, title="Onvif Port")
user: Optional[EnvString] = Field(default=None, title="Onvif Username")
password: Optional[EnvString] = Field(default=None, title="Onvif Password")
tls_insecure: bool = Field(default=False, title="Onvif Disable TLS verification")
autotracking: PtzAutotrackConfig = Field(
default_factory=PtzAutotrackConfig,
title="PTZ auto tracking config.",
Expand Down
7 changes: 6 additions & 1 deletion frigate/ptz/onvif.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from pathlib import Path

import numpy
import requests
from onvif import ONVIFCamera, ONVIFError
from zeep.exceptions import Fault, TransportError
from zeep.transports import Transport
Expand Down Expand Up @@ -48,7 +49,11 @@ def __init__(

if cam.onvif.host:
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] = {
"onvif": ONVIFCamera(
cam.onvif.host,
Expand Down
1 change: 1 addition & 0 deletions web/src/types/frigateConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export interface CameraConfig {
password: string | null;
port: number;
user: string | null;
tls_insecure: boolean;
};
record: {
enabled: boolean;
Expand Down

0 comments on commit ddfe8f3

Please sign in to comment.