keshavdv / unifi-cam-proxy

Enable non-Ubiquiti cameras to work with Unifi NVR
MIT License
1.71k stars 237 forks source link

Reoling doorbell adoption: SSL Error #289

Closed wookiesh closed 1 year ago

wookiesh commented 1 year ago

Camera

Reolink Doorbell POE

Firmware version of the camera

v3.0.0.0.1459_22102808

Description

Hi,

trying to have my new doorbell adopted by my unifi protect installation (thanks to the qr code URL tip), the following logs are displayed:


2023-03-30 18:42:41 6e77af13d094 Reolink[1] INFO Connecting to motion events API: http://10.0.0.249/api.cgi?cmd=GetMdState&user=*****&password=*****
2023-03-30 18:42:41 6e77af13d094 Reolink[1] ERROR Motion API request failed, retrying. Error: Cannot connect to host 10.0.0.249:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1108)')]

I have not been able to bypass the SSL verification nor to get the camera to not redirect to https.

How to reproduce

  1. in a docker compose file:
unifi-proxy-doorbell:
    image: keshavdv/unifi-cam-proxy
    volumes:
      - "./unifi-cam-proxy/client.pem:/client.pem:ro"
    command: unifi-cam-proxy --host 10.0.0.2 --cert /client.pem --token $UNIFI_ADOPTION_TOKEN --ip 10.0.0.249 reolink -u $REOLINK_DOORBELL_USERNAME -p $REOLINK_DOORBELL_PASSWORD -s "main" --ffmpeg-args='-c:v copy -vbsf "h264_metadata=tick_rate=60000/1001" -ar 32000 -ac 1 -codec:a aac -b:a 32k'

Expected behaviour

No errors

Screenshots

No response

Aditional information

I got a notification in my protect app that a g3 micro has tried to connect.

sferguson524 commented 1 year ago

Seeing the same thing with a Reolink RLC811

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

wookiesh commented 1 year ago

Stale alert, will do it just once :)

hotsoupp commented 1 year ago

This can be fixed by enabling HTTP in the settings of the doorbell. Sadly it completely breaks after running it. It connects and shows the first snapshot it grabs in UNIFI PROTECT, but the seems to be a issue with the code of unifi proxy as all the video streams die. I'll upload the logs later this weekend.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

greensmith commented 1 year ago

in the latest release (v0.2.0 (not main branch), the issue is that in cams/reolink.py the url is set to http and then the aiohttp.request isn't setting ssl=False.

async def get_snapshot(self) -> Path:
        img_file = Path(self.snapshot_dir, "screen.jpg")
        url = (
            f"https://{self.args.ip}"
            f"/cgi-bin/api.cgi?cmd=Snap&channel={self.args.channel}"
            f"&rs=6PHVjvf0UntSLbyT&user={self.args.username}"
            f"&password={self.args.password}"
        )
        self.logger.info(f"Grabbing snapshot: {url}")
        await self.fetch_to_file(url, img_file)
        return img_file

    async def run(self) -> None:
        url = (
            f"https://{self.args.ip}"
            f"/api.cgi?cmd=GetMdState&user={self.args.username}"
            f"&password={self.args.password}"
        )
        encoded_url = URL(url, encoded=True)

        body = (
            f'[{{ "cmd":"GetMdState", "param":{{ "channel":{self.args.channel} }} }}]'
        )
        while True:
            self.logger.info(f"Connecting to motion events API: {url}")
            try:
                async with aiohttp.ClientSession(
                    timeout=aiohttp.ClientTimeout(None)
                ) as session:
                    while True:
                        async with session.post(encoded_url, data=body, ssl=False) as resp:

modifying the docker image with these changes the camera gets adopted correctly to unifi and there are not more SSL errors - however, the camera stream never comes through and there are several errors about stdout/broken pipes caused by unifi/clock_sync.py

henryviana commented 2 months ago

I'm having the same problem with RLC-510A and RLC-520A cameras. Has anyone found any solution?