Delphi XE + SOAP + SSL

I have a program written in Delphi 2009. It uses SOAP over HTTP over SSL. Thus, the SOAP request launches the HTTP request, which is processed by Microsoft Internet Explorer through the DLL. Then MSIE will pop up asking for a username.

But now I need to compile it in Delphi XE, and I had a problem. the program does not want to enter SSL. No popup. Thus, it seems that the trigger does not 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); 

Error

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

Connection Procedure List

 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 part

 MantisConnectPortType = interface(IInvokable) 

a has an announcement:

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

In the browser and in the old exe built in 2009, everything works fine. Help solve this problem. Taras, Kiev

+6
source share
2 answers

If the Delphi 2009 exe "works fine" from the same PC , because you are testing exe Delphi XE, then some code probably (most likely) changed between the time when Delphi2009.exe was compiled and the time when you compiled DelphiXE. exe.

To check if the code is a problem, try recompiling the new code (from the Delphi XE version) in Delphi 2009 and see if it works. If this works, then Delphi XE seems to process certificates differently from Delphi 2009. If this does not work, then the code has changed significantly, in which case you will need to debug the code that takes the certificate from the certificate store.

Certificates can be installed in different places of the built-in Windows certificate store. Sometimes people just double-click and save the default values ​​in the Certificate Import Wizard (thus choosing "Automatically select the certificate location"), which can lead to the certificate being installed in the current_user certificate store. If this happens, exe will only be able to obtain a certificate if it runs under the same Windows user account.

The fact that you received the message "Authorization required" indicates a problem with the certificate. However, if you are testing from different computers, then there may also be problems with the firewall / corporate security.

+2
source

Your code works fine in Delphi XE2 and "Authorization Required", you may not be able to log in to mantis You may have changed your own password in your mantism account.

0
source

Source: https://habr.com/ru/post/887828/


All Articles