[DUG] Indy 9 and Secure HTTP
Chris Veale
CVeale at hortresearch.co.nz
Wed Jun 8 09:44:40 NZST 2005
In my application I have the following components...
IdConnectionIntercept
IdIPWatch
IdHttp
IdSSLIOHandlerSocket
and all I changed in the IdSSLIOHandlerSocket was to set up the method and the mode properties appropriately
Set the IOHandler property of the IdHTTP component to the IdSSLIOHandlerSocket component
Set the Intercept property of the IdHTTP component to the IdConnectionIntercept component
Set the Port of the IdHTTP component to 443
Set the appropriate Host method in the IdHTTP component
Make sure the Request-Content Type property is set to "application/x-www-form-urlencoded"
I also have the following function to retrieve the systems proxy settings that is called before the following code, I was also playing around with retrieving the username and password from the proxy server to resolve the need for getting my users to log into the system again, but didnt quite get that working, then time constraints and other projects...Im sure you know the story...
Anyways hope this helps for your issue...
Chris
{*****************************************************************}
{* *}
{* Procedure retrieves the current proxy server and port (from *}
{* the current connection) and loads the idhttp component with *}
{* these values *}
{* *}
{*****************************************************************}
procedure GetDefaultProxyServer(var Server, ByPass: string; var Port: Integer);
const
BUF_SIZE: DWORD = 500;
var
ProxyInfo: PInternetProxyInfo;
Buffer: Pointer;
httpspos,equalspos,colonpos,semipos:integer;
proxyname,proxyport,tmp:string;
begin
//allocate some memory
GetMem(Buffer, BUF_SIZE);
//try and retrieve the required data
try
//query the proxy information for the connetion
if not InternetQueryOption(nil, INTERNET_OPTION_PROXY, Buffer, BUF_SIZE) then
begin
//something went wrong so signal the error
RaiseLastWin32Error;
end;
//assign the structure with the result buffer
ProxyInfo := Buffer;
//set the bypass structure also
ByPass := ProxyInfo^.lpszProxyBypass;
//make sure we have proxy info in the structure
if (ProxyInfo^.lpszProxy = '') then
begin
Server := '';
Port := 0;
end
else
begin
//retrieve the https proxy name
httpspos := ansipos('https',ProxyInfo^.lpszProxy);
if httpspos <> 0 then
begin
tmp := copy(ProxyInfo^.lpszProxy,httpspos,1000);
semipos := ansipos(' ',tmp);
tmp := copy(tmp,1,semipos-1);
equalspos := ansipos('=',tmp);
colonpos := ansipos(':',tmp);
proxyname := copy(tmp,equalspos+1,colonpos-7);
proxyport := copy(tmp,colonpos+1,10);
//load the components bits
form2.IdHTTP1.ProxyParams.ProxyPort := strtoint(proxyport);
form2.IdHTTP1.ProxyParams.ProxyServer := proxyname;
end;
end;
finally
//free the memory
FreeMem(Buffer);
end;
end;{getdefaultproxyserver}
Then do the other code based tasks as follows
IdHTTP1.Request.Username := myUsername;
IdHTTP1.Request.Password := myPassword;
try
//authenticate to the server
IdHTTP1.Connect;
//do your other tasks
except
on e: EIdException do
begin
//I handle the response code here but just used showmessage to give you an idea
showmessage(e.message);
end;
on e: exception do
begin
showmessage(e.message);
end;
end;
>>> phil at tumonz.co.nz 8/06/2005 8:31:41 a.m. >>>
Has anyone solved the problem of fetching Secure HTTP with Indy 9? It no
longer has the TIdConnectionInterceptOpenSSL class defined with which to
use the OpenSSL dlls.
Phil.
_______________________________________________
Delphi mailing list
Delphi at ns3.123.co.nz
http://ns3.123.co.nz/mailman/listinfo/delphi
______________________________________________________
The contents of this e-mail are privileged and/or confidential to the
named recipient and are not to be used by any other person and/or
organisation. If you have received this e-mail in error, please notify
the sender and delete all material pertaining to this e-mail.
______________________________________________________
More information about the Delphi
mailing list