Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Webservice HTTPS Authorisation selbstsigniertes Zertifikat (https://www.delphipraxis.net/169943-webservice-https-authorisation-selbstsigniertes-zertifikat.html)

luigied 22. Aug 2012 07:08

Webservice HTTPS Authorisation selbstsigniertes Zertifikat
 
Guten Morgen,

wie in einem anderen Thema schon kurz erwähnt versuche ich einen SOAP-Webservice über HTTPS aufzurufen, der ein selbst-signiertes Zertifikat benutzt.

Ich besitze den Administrator-Zugang, das Zertifikat ist unter Windows installiert. Allerdngs bekomme ich vom Webservice die Meldung "Authorization Required (401)" zurück.

In welcher Komponente muss ich die Zugangsdaten übergeben?

Delphi-Quellcode:
HTTPRIO1.HTTPWebNode.UserName:='admin';
HTTPRIO1.HTTPWebNode.Password:='geheim123';
In der Eventbehandlung OnBeforePost der HTTPRIO-Komponente werden zusätzlich die InternetOptions gesetzt.

Delphi-Quellcode:
procedure TForm1.BeforePost(const HTTPReqResp: THTTPReqResp;
  Data: Pointer);
var
SecurityFlags: DWord;
SecurityFlagsLen: DWord;
Request: HINTERNET;
fUserName, fPassWd: String;
begin
  Request := Data;
  fUserName := 'admin';
  fPassWd := 'geheim123';
  if soIgnoreInvalidCerts in HTTPRIO1.HTTPWebNode.InvokeOptions then
  begin
    SecurityFlagsLen := SizeOf(SecurityFlags);
    InternetQueryOption(Request, INTERNET_OPTION_SECURITY_FLAGS,
    Pointer(@SecurityFlags), SecurityFlagsLen);
    SecurityFlags := SecurityFlags or SECURITY_FLAG_IGNORE_UNKNOWN_CA;
    InternetSetOption(Request, INTERNET_OPTION_SECURITY_FLAGS,
    Pointer(@SecurityFlags), SecurityFlagsLen);

    InternetSetOption(Request, INTERNET_OPTION_USERNAME, PChar(fUserName), Length(fUserName));
    InternetSetOption(Request, INTERNET_OPTION_PASSWORD, PChar(fPassWd), Length(fPassWd));
  end;
end;
Seltsamerweise wird diese Procedur laut Debugger garnicht aufgerufen. :shock:

Ich benötige mal einen Schupps indy richtige Richtung. :lol:

Danke schonmal.

Luigi


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:54 Uhr.

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