Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi IdHttp Auth Probleme 401/500 - TR-064 (https://www.delphipraxis.net/203273-idhttp-auth-probleme-401-500-tr-064-a.html)

tom77 30. Jan 2020 18:58


IdHttp Auth Probleme 401/500 - TR-064
 
Hallo zusammen,

ich versuche seit Stunden mich an einer fritz.box mittels idhttp und digest anzumelden(TR-064). Das Proggi läuft, sobald ich das Passwort von der fritz.box rausnehme.
Mit Passwort bekomme ich (abwechselnd) 401/500 Ausnahmen.
Laut Fiddler und Wireshark versucht idhttp es bis zu 4x sich zu authentifizieren. PHP und C# haben die Probleme nicht.

Für jede Hilfe Dankbar,

Tom

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);

var
  ss: TStringStream;
  test: UTF8String;

begin
     ss:=TStringStream.Create;
    Memo2.Lines.SaveToStream(ss);;
     IdHTTP1.ProtocolVersion:=pv1_1;
     IdHTTP1.Request.BasicAuthentication:= false;
     IdHTTP1.Request.ContentType:='text/xml; charset=utf-8';

     IdHTTP1.Request.CustomHeaders.FoldLines := false;
     IdHTTP1.Request.CustomHeaders.Values['SOAPAction']:='"urn:dslforum-org:service:X_AVM-DE_OnTel:1#GetPhonebook"';

     test:=IdHTTP1.Post('https://192.168.10.30:49000/upnp/control/x_contact',ss);
     Memo1.Lines.Add(test);
end;

Authentication: TIdAuthentication; var Handled: Boolean);
begin

  Authentication.Username:='xxx';
  Authentication.Password:='xxx';
  Handled:=true;
end;

Code:
POST /upnp/control/x_contact HTTP/1.0
Content-Type: text/xml; charset=utf-8
Content-Length: 415
SOAPAction: "urn:dslforum-org:service:X_AVM-DE_OnTel:1#GetPhonebook"
Connection: keep-alive
Host: 192.168.10.30:49000
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/3.0 (compatible; Indy Library)
Authorization: Digest username="xxx", realm="HTTPS Access", nonce="97E7957ABAFCA963", algorithm="MD5", uri="http://192.168.10.30:49000/upnp/control/x_contact", qop="auth", nc=00000001, cnonce="6919ca5976ad468de57be7ab41bedd53", response="ec38b586b80651891741d368ad4382d3"

<?xml version="1.0" encoding="utf-8"?>
   <s:Envelope
   xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
   s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <s:Body>
   <u:GetPhonebook xmlns:u="urn:dslforum-org:service:X_AVM-DE_OnTel:1">
   <NewPhonebookID xsi:type="xsd:int">0</NewPhonebookID>
   </u:GetPhonebook>
   </s:Body>
   </s:Envelope>
HTTP/1.0 401 Unauthorized
Content-Length: 170
Content-Type: text/html
Pragma: no-cache
Server: Webserver
WWW-Authenticate: Digest realm="HTTPS Access",nonce="8F17EC1501B966BD",algorithm=MD5,qop="auth"

<HTML><HEAD><TITLE>401 Unauthorized (ERR_NONE)</TITLE></HEAD><BODY><H1>401 Unauthorized</H1><BR>ERR_NONE<HR><B>Webserver</B> Thu, 30 Jan 2020 18:53:08 GMT</BODY></HTML>

HolgerX 31. Jan 2020 07:05

AW: IdHttp Auth Probleme 401/500
 
Hmm..

Dir ist schon bewusst, dass für die Anmeldung an der FritzBox seit OS Vers. 5.5 eine SID (SessionID) verwendet wird?

https://avm.de/fileadmin/user_upload...ch_13Nov18.pdf

https://codedocu.de/Details?d=1334&a=13&f=116&l=1&v=d

Somit musst Du erst eine Session starten (über http://fritz.box/login_sid.lua ) und diese dann für deine Zugriffe in der URL angeben.

Somit genügt ein HTTP-Request nicht alleine für z.B. die Abfrage der Anruferliste..

tom77 31. Jan 2020 09:31

AW: IdHttp Auth Probleme 401/500
 
Hallo Holger,

danke für Deine schnelle Antwort. Ich werde das mit der SessionId auf jeden Fall ausprobieren!

Das erklärt Allerdings nicht, warum C# und PHP das Problem nicht haben ;-)

tom77 31. Jan 2020 13:26

AW: IdHttp Auth Probleme 401/500
 
scheinbar sind Webinterface und TR-064 getrennt. Ich habe versucht die sid an die URL anzuhängen, bekomme aber den gleichen Fehler.

Wenn ich das ganze mit C# mache, bekomme ich aber eine URL via TR-064 geliefert. Diese hat dann schon eine sid.

Code:
<NewPhonebookURL>http://192.168.10.30:49000/phonebook.lua?sid=b55b9ed06c8bfff5&amp;pbid=0</NewPhonebookURL>

tom77 31. Jan 2020 21:49

AW: IdHttp Auth Probleme 401/500 - TR-064
 
Beim stöbern hier im Forum, bin ich darauf gestoßen, daß es den TNetHTTPClient gibt.

Mit dem funzt es problemlos :-D


Alle Zeitangaben in WEZ +1. Es ist jetzt 17:11 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz