Jump to content

Recommended Posts

Trying for days to communicate to an IP camera from an apache server using PHP

I do get responses from the camera

RTSP/1.0 401 Unauthorized CSeq: 1 WWW-Authenticate: Digest realm="Login to 3E072F5PAL00180", nonce="bf2693784e774fb41b569ca02d8abe54"

The nonce changes each time I refresh, I guess that is exactly what It should do.

I read that I must MD5 the user and password along with some other data and create a string that goes back to the camera to authenticate and once done the  camera replies RTSP/1.0 200 OK

Somebody has a small bit of code to build the required answer from strings?

I am not big in PHP,

 

I did find this on a page but it is way over my head, I do not have anything called $data.

 



$A1 = md5($data['username'] . ':' . $realm . ':' . $users[$data['username']]);
$A2 = md5($_SERVER['REQUEST_METHOD'].':'.$data['uri']);
$valid_response = md5($A1.':'.$data['nonce'].':'.$data['nc'].':'.$data['cnonce'].':'.$data['qop'].':'.$A2);

 

I get the idea of sending commands with an existing socket. socket_write($socket,$answer);


NONCE :62d72a3d3b35bb5440ba29222e3669aa
REALM :Login to 3E072F5PAL00180
User :
Password :

I have assigned directly as strings the password and user.

 

 

 

 

Hello requinix Sadly no, I cannot connect to the camera with basic auth, or at least I could not find any details on how to do that. It seams that basic auth is out dated.

I do see a lot of curl expamples and I tried loads, but none I found work with a camera behind a forwarded port like 554, using curl is quite common but as I understand it is reading via a html connection not rtsp. Of course I could also be wrong.

I use delphi mostly so PHP is mind boggling for me.

 

As I understand it, the camera is basically asking me to login.

How I send the login data is what I am stuck with.

 

So far I am creating a socket to communicate with the camera then perform a basic request "Describe" to the camera

Socket Create result: Success

Sent to the Camera:DESCRIBE rtsp://IP:554 RTSP/1.0 CSeq: 1

The Camera Responded with
RTSP/1.0 401 Unauthorized CSeq: 1 WWW-Authenticate: Digest realm="Login to 3E072F5PAL00180", nonce="f683e059c7c09ca8511322793dc99d2c"

NONCE :f683e059c7c09ca8511322793dc99d2c
REALM :Login to 3E072F5PAL00180

I then extract nonce and realm from the camera response into these parts $nonce and $realm, I think then I should combine these with the username, password and send back to the camera as a message to perform the login.  It is that message that I am lost how to do.

 

 

 

 

 

First question: did you do an rtsp OPTIONS request?

OPTIONS rtsp://IP:554 RTSP/1.0

What is the reply?

As for Digest authentication,  just interpreting this page, I would start with:

  1. HA1 = MD5(username:realm:password)
  2. HA2 = MD5(method:digestURI)
  3. response = MD5(HA1:nonce:HA2)

Assuming you have set username and password as variables:

$ha1 = md5($username . ':' . $realm . ':' . $password); 
$ha2 = md5('rtsp://IP:554');

$response = md5($ha1 . ':' $nonce . ':' . $ha2);

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.