EldoS | Feel safer!

Software components for data protection, secure storage and transfer

smime

Also by EldoS: CallbackProcess
A component to control process creation and termination in Windows and .NET applications.
#4163
Posted: 10/26/2007 12:35:06
by Marc Salama (Basic support level)
Joined: 10/26/2007
Posts: 1

I use the evaluation version of securityblackbox.
I need to send smime message with x509 certificate

i write the code



procedure TForm23.Button1Click(Sender: TObject);
var
St1, St2: TMemoryStream;
st3: TFIleStream;
Res: Integer;
SBCertFileFormat: TSBCertFileFormat;
begin

IdMessage1.From.Address := 'marc@salama.fr';
IdMessage1.Recipients.Add.Address := 'marc@salama.fr';
IdMessage1.Subject := 'test blackBox';
IdMessage1.Body.Add('Hello');
TIdAttachment.Create(IdMessage1.MessageParts, 'e:\project\paramed\b2\00080.b2');

st3 := TFIleStream.Create('d:\openssl\certmarc', fmOpenRead);
ElX509Certificate1.LoadFromStream(St3);
SBCertFileFormat := ElX509Certificate1.DetectCertFileFormat('d:\openssl\certmarc'); //result=cfder this certificate has only public key
ElFileCertStorage1.Add(ElX509Certificate1);
ElMessageEncryptor1.CertStorage := ElFileCertStorage1;
ElMessageEncryptor1.Algorithm := SB_ALGORITHM_CNT_3DES;
ElMessageEncryptor1.BitsInKey := 1024;
St1 := TMemoryStream.Create;
St2 := TMemoryStream.Create;
IdMessage1.SaveToStream(St1);

try
res := ElMessageEncryptor1.Encrypt(St1, st2);
if Res = 0 then
begin
IdMessage1.Body.loadFromFile('d:\openssl\toto1.txt');
IdMessage1.Body.SaveToFile('d:\openssl\body2.txt');
IdSMTP1.Connect;
IdSMTP1.Send(IdMessage1);
IdSMTP1.Disconnect;

St1.Destroy;
St2.Destroy;
end;

except
on e: exception do Panel1.Caption := e.Message;
end;
Panel1.Caption := Panel1.Caption + ' ' + IntToStr(res);
end;
res is equal to 0 but the message i receive is not crypted.

How shall i do

Thanks for your help and sorry for my bad english


Marc Salama
#4164
Posted: 10/26/2007 12:45:53
by Ken Ivanov (EldoS Corp.)

Your code is not correct. ElMessageEncryptor class has nothing common with S/MIME. Please use the samples included to the distribution (SecureMail, MimeMaker) as a guide.

Reply

Statistics

Topic viewed 1733 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!