|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Member
Iscritto dal: Nov 2002
Messaggi: 250
|
[Delphi] integrare librerie SSL
Ciao ragazzuoli,
Sto scrivendo un programmino in delphi per controllarmi la posta da gmail. Sono arrivato al punto di integrare le funzionalità del protocollo TLS tramite le dll offerte da OpenSSL ma niente da fare: il codegear mi solleva l'eccezione EIdOSSLCouldNotLoadSSLLibrary quando provo a connettermi al server POP3 tramite pop.Connect; Avete qualche idea? Ci sono parametri particolari da impostare? Attualmente uso CodeGear Delphi 2007 WIN32, e le librerie Indy 10.1.5 Ho letto cercando su google che probabilmente è un problema legato alla versione delle DLL (libssl32.dll e libeay32.dll), ma le ho provate tutte...dalla 0.9.7c alla 0.9.8h Questo è il codice semplice semplice: Codice:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdIOHandler, IdIOHandlerSocket, IdIOHandlerStack, IdSSL,
IdSSLOpenSSL, IdMessage, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdExplicitTLSClientServerBase, IdMessageClient, IdPOP3;
type TForm2 = class(TForm)
Button1: TButton;
pop: TIdPOP3;
msg: TIdMessage;
IdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
var n,i:integer;
begin
pop.Connect;
n:=pop.CheckMessages;
listbox1.Items.Add(format('There are %d messages',[n]));
for i:=0 to n-1 do
begin
pop.Retrieve(i,msg);
listbox1.Items.Add(format('%d - %s',[i,msg.Subject]));
application.ProcessMessages;
end;
pop.Disconnect;
end;
end.
E questo è il codice della form: Codice:
object Form2: TForm2
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 344
ClientWidth = 412
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 16
Top = 16
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 0
OnClick = Button1Click
end
object ListBox1: TListBox
Left = 32
Top = 72
Width = 345
Height = 265
ItemHeight = 13
TabOrder = 1
end
object pop: TIdPOP3
IOHandler = IdSSLIOHandlerSocketOpenSSL1
AutoLogin = True
Host = 'pop.gmail.com'
Username = '[email protected]'
UseTLS = utUseImplicitTLS
Password = '########'
Port = 995
SASLMechanisms = <>
Left = 208
Top = 16
end
object msg: TIdMessage
AttachmentEncoding = 'UUE'
BccList = <>
CCList = <>
Encoding = meDefault
FromList = <
item
end>
Recipients = <>
ReplyTo = <>
ConvertPreamble = True
Left = 304
Top = 24
end
object IdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL
Destination = 'pop.gmail.com:995'
Host = 'pop.gmail.com'
MaxLineAction = maException
Port = 995
DefaultPort = 0
SSLOptions.Method = sslvSSLv2
SSLOptions.Mode = sslmUnassigned
SSLOptions.VerifyMode = []
SSLOptions.VerifyDepth = 0
Left = 160
Top = 32
end
end
Ovviamente le due DLL le ho messe nella stessa cartella del progetto e del .exe ma niente... ho provato anche a metterle in system32 ma nada anche li.... |
|
|
|
|
|
#3 |
|
Senior Member
Iscritto dal: Mar 2007
Messaggi: 1792
|
Come alternativa puoi usare la libreria Synapse, è più leggera della Indy e non richiede librerie compilate ad hoc.
|
|
|
|
|
|
#4 |
|
Member
Iscritto dal: Nov 2002
Messaggi: 250
|
Atanor, da quello che ho capiro dalla versione 10 di Indi vanno usate le librerie standard OpenSSL. Infatti provando con la versione 0.96m tutto funziona
|
|
|
|
|
|
#5 |
|
Member
Iscritto dal: Nov 2002
Messaggi: 250
|
ragazzuoli, mi sto divertendo un sacco
Sto provando Synapse, però non riesco a compilare correttamente le librerie: sembra che il mio CodeGear Delphi 2007 non riconosca le direttive "include" del tipo: {$I sswin32.pas} Avete qualche idea? |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 16:54.



















