Delphi 2007 Indy 10 找不到 SSL 库
Delphi 2007 Indy 10 Cannot find SSL library
我正在使用 Delphi 2007 和 Indy 10 发出 https post 请求,我正在使用 httpbin
进行测试,但它不起作用......它正在提高:
First chance exception at 503E28. Exception class EIdOSSLCouldNotLoadSSLLibrary with message 'Could not load SSL library.'. Process Recarga.exe (21392)
这是我的代码:
unit UMAIN;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdHttp, IdMultipartFormData, IdSSLOpenSSL;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
const
URL = 'https://httpbin.org/post';
var
idHttp: TIdHTTP;
data: TIdMultiPartFormDataStream;
retorno: string;
LHandler: TIdSSLIOHandlerSocketOpenSSL;
begin
idHttp:= TIdHTTP.Create(nil);
data := TIdMultiPartFormDataStream.Create;
LHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
with LHandler do
begin
SSLOptions.Method := sslvSSLv2;
SSLOptions.Mode := sslmUnassigned;
SSLOptions.VerifyMode := [];
SSLOptions.VerifyDepth := 0;
host := '';
end;
data.AddFormField('serv', 'atualizar');
try
try
idHttp.IOHandler := LHandler;
idHttp.Request.Accept := 'text/html, */*';
idHttp.Request.UserAgent := 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0';
idHttp.Request.ContentType := 'application/x-www-form-urlencoded';
idHttp.HandleRedirects := True;
retorno := UTF8Decode(idHttp.Post(URL, data));
ShowMessage('Resultado: ' + retorno);
except on E: Exception do
ShowMessage('Erro: ' + E.Message);
end;
finally
LHandler.Free;
idHttp.Free;
end;
end;
end.
我在 SO 和其他我需要 libeay32.dll 和 ssleay32.dll 库的网站上被读到但是我确实有它们,并且位于我最终 exe 所在的同一目录中,但没有任何效果,正如我上面所说的。怎么了?这是一个错误吗?
根据 this answer I needed a specific version of the dlls. After struggling and testing all openssl versions provided by Indy, the 9.6 one 为我工作的说法,在让一个 dll 工作之前,我必须测试许多 dll。
我正在使用 Delphi 2007 和 Indy 10 发出 https post 请求,我正在使用 httpbin
进行测试,但它不起作用......它正在提高:
First chance exception at 503E28. Exception class EIdOSSLCouldNotLoadSSLLibrary with message 'Could not load SSL library.'. Process Recarga.exe (21392)
这是我的代码:
unit UMAIN;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdHttp, IdMultipartFormData, IdSSLOpenSSL;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
const
URL = 'https://httpbin.org/post';
var
idHttp: TIdHTTP;
data: TIdMultiPartFormDataStream;
retorno: string;
LHandler: TIdSSLIOHandlerSocketOpenSSL;
begin
idHttp:= TIdHTTP.Create(nil);
data := TIdMultiPartFormDataStream.Create;
LHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
with LHandler do
begin
SSLOptions.Method := sslvSSLv2;
SSLOptions.Mode := sslmUnassigned;
SSLOptions.VerifyMode := [];
SSLOptions.VerifyDepth := 0;
host := '';
end;
data.AddFormField('serv', 'atualizar');
try
try
idHttp.IOHandler := LHandler;
idHttp.Request.Accept := 'text/html, */*';
idHttp.Request.UserAgent := 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0';
idHttp.Request.ContentType := 'application/x-www-form-urlencoded';
idHttp.HandleRedirects := True;
retorno := UTF8Decode(idHttp.Post(URL, data));
ShowMessage('Resultado: ' + retorno);
except on E: Exception do
ShowMessage('Erro: ' + E.Message);
end;
finally
LHandler.Free;
idHttp.Free;
end;
end;
end.
我在 SO 和其他我需要 libeay32.dll 和 ssleay32.dll 库的网站上被读到但是我确实有它们,并且位于我最终 exe 所在的同一目录中,但没有任何效果,正如我上面所说的。怎么了?这是一个错误吗?
根据 this answer I needed a specific version of the dlls. After struggling and testing all openssl versions provided by Indy, the 9.6 one 为我工作的说法,在让一个 dll 工作之前,我必须测试许多 dll。