procedure TForm1.DoSSLStatusInfoEx(ASender: TObject;
const AsslSocket: PSSL;
const AWhere, Aret: Integer;
const AType,
AMsg:
string);
var
I, K, L: Integer;
B: Byte;
C: AnsiChar;
LClientRandom, LMasterSecret, LLogLine: AnsiString;
LMode: Word;
S3: Pssl3_state;
FS: TFileStream;
begin
if Assigned(AsslSocket)
and
Assigned(AsslSocket^.session)
and
Assigned(AsslSocket^.s3)
and
(FMasterSecretFile <> '
')
then
begin
L := Length(AsslSocket^.session^.master_key) - 1;
for I := 0
to L
do begin
B := AsslSocket^.session^.master_key[I];
LMasterSecret := LMasterSecret + Format('
%2.2x', [B]);
if (I = L)
and (LMasterSecret <> StringOfChar('
0', (L+1)*2))
then begin
L := Length(AsslSocket^.s3^.client_random) - 1;
for K := 0
to L
do begin
S3 := AsslSocket^.s3;
Dec(PByte(S3));
// <-- Bug irgendwo zwischen OpenSSL-DLL und Indy, Speicher von ASslSocket.S3 um ein Byte verschoben
C := s3^.client_random[K];
B := Ord(C);
LClientRandom := LClientRandom + Format('
%2.2x', [B]);
if K = L
then begin
LLogLine := '
CLIENT_RANDOM ' + LClientRandom + '
' +
LMasterSecret + sLineBreak;
if LLogLine <> FLastMasterSecretLine
then begin
LMode := (fmOpenReadWrite
or fmShareDenyNone);
if not FileExists(FMasterSecretFile)
then begin
LMode := fmCreate
or LMode;
end;
FS := TFileStream.Create(FMasterSecretFile, LMode);
try
FS.Position := FS.Size;
FS.
Write(LLogLine[1], Length(LLogLine));
Exit;
finally
FLastMasterSecretLine := LLogLine;
FreeAndNil(FS);
end;
end;
end;
end;
end;
end;
end;
end;