Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi XE + SOAP + SSL

I have a program that was written on Delphi 2009. It uses SOAP over HTTP over SSL. So it is the SOAP request that triggers an HTTP request, which is handled by Microsoft Internet Explorer via a DLL. MSIE will then make a popup that asks for login.

But now I need to compile it in Delphi XE and I got a problem. program does not want to login in SSL. No popup at all. So, it seems that trigger doesn't want to work.

The error appears in the second line of this code:

mantis:=GetMantisConnectPortType(false, mantisurl);
mi := mantis.mc_issue_get(username,password,MantisIssue);

The error is

Project IssueReporter.exe raised exception class ESOAPHTTPException with message 'Authorization Required (401) - 'https://***/mantis/api/soap/mantisconnect.php''.

Listing of the connection procedure is

function GetMantisConnectPortType(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): MantisConnectPortType;
const
  defWSDL = 'https://***/mantis/api/soap/mantisconnect.php?wsdl';
  defURL  = 'https://***/mantis/api/soap/mantisconnect.php';
  defSvc  = 'MantisConnect';
  defPrt  = 'MantisConnectPort';
var
  RIO: THTTPRIO;
begin
  Result := nil;
  if (Addr = '') then
  begin
    if UseWSDL then
      Addr := defWSDL
    else
      Addr := defURL;
  end;
  if HTTPRIO = nil then
    RIO := THTTPRIO.Create(nil)
  else
    RIO := HTTPRIO;
  try
    Result := (RIO as MantisConnectPortType);
    if UseWSDL then
    begin
      RIO.WSDLLocation := Addr;
      RIO.Service := defSvc;
      RIO.Port := defPrt;
    end else
      RIO.URL := Addr;
  finally
    if (Result = nil) and (HTTPRIO = nil) then
      RIO.Free;
  end;
end;

mc_issue_get is a part of

MantisConnectPortType = interface(IInvokable)

an has the declaration:

function  mc_issue_get(const username: string; const password: string; const issue_id: Int64): IssueData; stdcall;

In the browser and in the old exe compiled in 2009 all works fine. Help please to resolve this problem. Taras, Kyiv

like image 578
Taras Avatar asked May 11 '11 12:05

Taras


1 Answers

If the Delphi 2009 exe "works fine" from the same pc as you're testing the Delphi XE exe, then some code has probably (most likely) changed between the time the Delphi2009.exe was compiled and the time you compiled the DelphiXE.exe.

To test if the code is the problem, try to recompile new code (from Delphi XE version) in Delphi 2009 and see if that works. If it works, then Delphi XE probably handles certificates differently to Delphi 2009. If it doesn't work then the code has changed substantially, in which case you'll need to debug the code that picks up the certificate from the certificate store.

Certificates can be installed into various locations within the built-in Windows certificate store. Sometimes, people just double-click, and keep the defaults in the certificate import wizard (thereby selecting Automatically choose certificate location) which may result in the certificate being installed in the current_user's certificate store. If that happens, then the exe will only be able to pick up the certificate if running under the same windows user account.

The fact that you got an Authorization Required message points to a certificate issue. However if you're testing from different PC's then there could also be firewall/enterprise security issues.

like image 135
Sam Avatar answered Nov 11 '22 08:11

Sam