Hallo zusammen,
Leider habe ich es nach vielem suchen im Forum nicht geschafft, einen Snapshot URL Aufruf zu meiner Amcrest Webcam (ehemals foscam) hin zu bekommen. Mit dem Urlaufruf wird ein Foto im Browser geladen und automatisch von der Kamera auch auf einem Server abgelegt.
Im Chrome und Edge browser funktioniert der Aufruf. Die URL lautet 'http://user:passwort@192.168.28.49/cgi-bin/snapshot.cgi?channel=1'.
Zunächst habe ich verstanden, dass der Aufruf mit Digest authentication passieren muss. Dazu habe ich mir die verschiedenen Methoden des HttpUtils Moduls angesehen und ausprobiert. Insbesondere HttpUtils_BlockingGet unterstützt Digest authentication. Leider bekomme bei allen Versuchen am Ende immer wieder eine "wrong authentication" und finde meinen Fehler nicht.
Hoffe ihr habe eine Idee, die mich weiter bringt.
Hier der Code der aus einem notify aufgerufen wird:
BM.vorn:motion {
Log 1, "---------------------log GetFileFromUrl start";
GetFileFromURL('http://192.168.28.49/cgi-bin/snapshot.cgi?channel=1','15','','0','1'); Log 1, "done";
Log 1, "---------------------log GetFileFromUrl with User pwd start";
GetFileFromURL('http://user:passwort@192.168.28.49/cgi-bin/snapshot.cgi?channel=1','15','','0','1'); Log 1, "done";
Log 1, "---------------------log blocking get start";
my $HttpResponse=" ";
my $HttpResponseErr=" ";
my $sslparams = { SSL_verify_mode => 0, sslOpt2 => 'sslVal2' };
my $myurl = 'http://user:passwort@192.168.28.49/cgi-bin/snapshot.cgi?channel=1';
my $param = {url => $myurl, httpversion => '1.1', method => 'get', timeout => '9', loglevel => '1', sslargs => $sslparams, digest => '1'};
Log 1, "log blocking get Parma".$param;
($HttpResponseErr, $HttpResponse) = HttpUtils_BlockingGet($param);
Log 1, "log blocking get HttpResponseErr:" .$HttpResponseErr;
Log 1, "log blocking get HttpResponse".$HttpResponse;
}
Im log findet man dann folgendes:
2017.07.30 09:12:11 1: ---------------------log GetFileFromUrl start
2017.07.30 09:12:11 1: HttpUtils url=http://192.168.28.49/cgi-bin/snapshot.cgi?channel=1
2017.07.30 09:12:11 2: HttpUtils request header:
GET /cgi-bin/snapshot.cgi?channel=1 HTTP/1.0
Host: 192.168.28.49
User-Agent: fhem
Content-Length: 0
Content-Type: application/x-www-form-urlencoded
2017.07.30 09:12:11 1: http://192.168.28.49/cgi-bin/snapshot.cgi?channel=1: HTTP response code 401
2017.07.30 09:12:11 1: HttpUtils http://192.168.28.49/cgi-bin/snapshot.cgi?channel=1: Got data, length: 0
2017.07.30 09:12:11 2: HttpUtils response header:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Digest realm="Login to A5348DA22",qop="auth",nonce="1334772413",opaque="3a139540c6"
Connection: close
CONTENT-LENGTH: 0
2017.07.30 09:12:11 1: done
2017.07.30 09:12:11 1: ---------------------log GetFileFromUrl with User pwd start
2017.07.30 09:12:11 1: HttpUtils url=http://user:passwort@192.168.28.49/cgi-bin/snapshot.cgi?channel=1
2017.07.30 09:12:11 2: HttpUtils request header:
GET /cgi-bin/snapshot.cgi?channel=1 HTTP/1.0
Host: 192.168.28.49
User-Agent: fhem
Authorization: Basic sZXg=
Content-Length: 0
Content-Type: application/x-www-form-urlencoded
2017.07.30 09:12:11 1: http://user:passwort@192.168.28.49/cgi-bin/snapshot.cgi?channel=1: HTTP response code 401
2017.07.30 09:12:11 1: HttpUtils url=http://user:passwort@192.168.28.49/cgi-bin/snapshot.cgi?channel=1
2017.07.30 09:12:11 2: HttpUtils request header:
GET /cgi-bin/snapshot.cgi?channel=1 HTTP/1.0
Host: 192.168.28.49
User-Agent: fhem
Authorization: Digest response="4b1fcbcc4", username="admin", uri="/cgi-bin/snapshot.cgi?channel=1", opaque="86ab5b2"
Content-Length: 0
Content-Type: application/x-www-form-urlencoded
2017.07.30 09:12:11 1: http://user:passwort@192.168.28.49/cgi-bin/snapshot.cgi?channel=1: HTTP response code 401
2017.07.30 09:12:11 1: CustomGetFileFromURL http://user:passwort@192.168.28.49/cgi-bin/snapshot.cgi?channel=1: wrong authentication
2017.07.30 09:12:11 1: done
2017.07.30 09:12:11 1: ---------------------log blocking get start
2017.07.30 09:12:11 1: log blocking get ParmaHASH(0x2955a78)
2017.07.30 09:12:11 1: HttpUtils url=http://user:passwort@192.168.28.49/cgi-bin/snapshot.cgi?channel=1
2017.07.30 09:12:11 2: HttpUtils request header:
get /cgi-bin/snapshot.cgi?channel=1 HTTP/1.1
Host: 192.168.28.49
User-Agent: fhem
Connection: Close
2017.07.30 09:12:11 1: http://user:passwort@192.168.28.49/cgi-bin/snapshot.cgi?channel=1: HTTP response code 401
2017.07.30 09:12:11 1: HttpUtils url=http://user:passwort@192.168.28.49/cgi-bin/snapshot.cgi?channel=1
2017.07.30 09:12:11 2: HttpUtils request header:
get /cgi-bin/snapshot.cgi?channel=1 HTTP/1.1
Host: 192.168.28.49
User-Agent: fhem
Connection: Close
Authorization: Digest response="585f252", username="admin", uri="/cgi-bin/snapshot.cgi?channel=1", opaque="3a139540c6"
2017.07.30 09:12:11 1: http://user:passwort@192.168.28.49/cgi-bin/snapshot.cgi?channel=1: HTTP response code 401
2017.07.30 09:12:11 1: log blocking get HttpResponseErr:http://user:passwort@192.168.28.49/cgi-bin/snapshot.cgi?channel=1: wrong authentication
2017.07.30 09:12:11 1: log blocking get HttpResponse
Hallo Sven,
wenn es nur im Chrome und im IE / Edge auch nicht funktioniert, dann würde ich erst mal mit Burp genau ansehen, wo die relevanten Unterschiede bei den Requests sind. Eventuell ist nicht nur die Authentisierung das Problem. Sobald Du mit Burp einen funktionierenden Ablauf hast, müsstest Du es mit HTTPMOD nachbauen können.
Gruss
Stefan
Hallo,
Bin da beim loggen mit Burp nicht wirklich weiterkommen. Habe aber festgestellt, dass der Aufruf über Chrom und edge gleich funktioniert. Möglicherweise liegt das burp logging Problem aber auch am vpn, bin die nächsten Wochen nicht lokal.Grundsätzlich sollte es aber auch über den oben dargestellten Httputils Aufruf funktionieren. @Markus Bloch hatte dies implementiert und Digest ermöglicht.https://forum.fhem.de/index.php?topic=43043.0#ratethis (https://forum.fhem.de/index.php?topic=43043.0#ratethis)
@Markus, kannst Du hier nochmals draufsehen?
Danke Sven
Hallo Sven,
ich habe in dem genannten Thread aus dem FHEM Development-Bereich eine Änderung vorgeschlagen um dein Problem zu beheben.
Viele Grüße
Markus
Hallo Markus, sorry für die spätere Antwort.
Jetzt läuft alles super. nochmals vielen Dank.
Für die die es selbst umsetzten wollen. Digest authentication zugriff auf eine Amcrest / (foscam Nachfolger) Webcam geht bei mir über folgenden Aufruf:
GetFileFromURL('https://user:passwort@192.168.28.49/cgi-bin/snapshot.cgi?channel=1','15','','0','1'); Log 1, "done";