Skip to content

Commit

Permalink
Certs update. DLL libs update - build statically without crtruntime r…
Browse files Browse the repository at this point in the history
…equirement.
  • Loading branch information
mirus77 committed Aug 1, 2019
1 parent 08ae944 commit 0d240c6
Show file tree
Hide file tree
Showing 29 changed files with 64 additions and 46 deletions.
Binary file modified bin/libeay32.dll
Binary file not shown.
Binary file modified bin/libeetsigner.dll
Binary file not shown.
Binary file modified bin/libexslt.dll
Binary file not shown.
Binary file removed bin/libiconv.dll
Binary file not shown.
Binary file modified bin/libxml2.dll
Binary file not shown.
Binary file modified bin/libxmlsec-mscrypto.dll
Binary file not shown.
Binary file modified bin/libxmlsec-openssl.dll
Binary file not shown.
Binary file modified bin/libxmlsec.dll
Binary file not shown.
Binary file modified bin/libxslt.dll
Binary file not shown.
Binary file modified bin/ssleay32.dll
Binary file not shown.
Binary file modified bin64/libeay32.dll
Binary file not shown.
Binary file modified bin64/libeetsigner.dll
Binary file not shown.
Binary file modified bin64/libexslt.dll
Binary file not shown.
Binary file modified bin64/libxml2.dll
Binary file not shown.
Binary file modified bin64/libxmlsec-mscrypto.dll
Binary file not shown.
Binary file modified bin64/libxmlsec-openssl.dll
Binary file not shown.
Binary file modified bin64/libxmlsec.dll
Binary file not shown.
Binary file modified bin64/libxslt.dll
Binary file not shown.
Binary file modified bin64/ssleay32.dll
Binary file not shown.
Binary file modified cert/EET_CA1_Playground-CZ00000019.p12
Binary file not shown.
Binary file modified cert/EET_CA1_Playground-CZ1212121218.p12
Binary file not shown.
Binary file modified cert/EET_CA1_Playground-CZ683555118.p12
Binary file not shown.
File renamed without changes.
File renamed without changes.
Binary file removed cert/trusted_CA_pg.der
Binary file not shown.
12 changes: 6 additions & 6 deletions demo/u_main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,8 @@ procedure TTestEETForm.btnVerifyResponseClick(Sender: TObject);
ms := TMemoryStream.Create;
try
lSigner.LoadPFXCertFromFile(ExpandFileName('..\cert\EET_CA1_Playground-CZ00000019.p12'), 'eet');
lSigner.AddTrustedCertFromFileName(ExpandFileName('..\cert\trusted_CA_pg.der'));
lSigner.AddTrustedCertFromFileName(ExpandFileName('..\cert\trusted_CA_prod.der'));
lSigner.AddTrustedCertFromFileName(ExpandFileName('..\cert\trusted_CA_prod_ROOT.der'));
lSigner.AddTrustedCertFromFileName(ExpandFileName('..\cert\trusted_CA.der'));
lSigner.AddTrustedCertFromFileName(ExpandFileName('..\cert\trusted_CA_ROOT.der'));
ms.LoadFromFile('response.xml');
lSigner.Active := true;
if lSigner.VerifyXML(ms, 'Body', 'Id') then
Expand Down Expand Up @@ -180,9 +179,8 @@ procedure TTestEETForm.DoSendRevenue;
// EET.URL := 'https://prod.eet.cz:443/eet/services/EETServiceSOAP/v3';
EET.OnVerifyResponse := VerifyResponseCert;
EET.Signer.LoadPFXCertFromFile(ExpandFileName('..\cert\EET_CA1_Playground-CZ00000019.p12'), 'eet');
EET.Signer.AddTrustedCertFromFileName(ExpandFileName('..\cert\trusted_CA_pg.der'));
EET.Signer.AddTrustedCertFromFileName(ExpandFileName('..\cert\trusted_CA_prod.der'));
EET.Signer.AddTrustedCertFromFileName(ExpandFileName('..\cert\trusted_CA_prod_ROOT.der'));
EET.Signer.AddTrustedCertFromFileName(ExpandFileName('..\cert\trusted_CA.der'));
EET.Signer.AddTrustedCertFromFileName(ExpandFileName('..\cert\trusted_CA_ROOT.der'));
EET.Initialize; { * init signer * }

lblKeySubject.Caption := 'Certificate Subject :' + EET.Signer.PrivKeyInfo.CommonName;
Expand Down Expand Up @@ -295,6 +293,8 @@ procedure TTestEETForm.DoSendRevenue;
begin
if EET.ErrorCode <> 0 then
ShowMessageFmt('Error : %d - %s', [EET.ErrorCode, EET.ErrorMessage]);
if Odp = nil then
ShowMessageFmt('Error : %s', ['Invalid response']);
end;
synmResponse.Lines.Add('<!-- PKP : ' + eTrzba.KontrolniKody.pkp.Text + ' -->');
mmoLog.Lines.Add('ResponseCert : Subject ' + EET.Signer.ResponseCertInfo.Subject + ', Common Name : ' + EET.Signer.ResponseCertInfo.CommonName);
Expand Down
89 changes: 54 additions & 35 deletions source/eet/u_EETSigner.pas
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ procedure EETSigner_EVP_MD_CTX_cleanup(ctx: pEVP_MD_CTX); cdecl;
implementation

uses
StrUtils, DateUtils, {$IF RTLVersion >= 25 }AnsiStrings,{$IFEND}
StrUtils, DateUtils, SyncObjs, {$IF RTLVersion >= 25 }AnsiStrings,{$IFEND}
{$IFNDEF USE_LIBEET}
libxmlsec_openssl,
{$IFDEF USE_SYNACODE}synacode,{$ENDIF}
Expand All @@ -139,6 +139,7 @@ implementation

var
EETSignerCount: integer = 0;
Lock: TCriticalSection;

{$IFNDEF USE_LIBEET}
{$IFNDEF USE_SYNACODE}
Expand Down Expand Up @@ -182,7 +183,6 @@ procedure TEETSigner.ClearVerifyCert;

constructor TEETSigner.Create(AOwner: TComponent);
begin
Inc(EETSignerCount);
InitXMLSec;
inherited Create(AOwner);
FPFXStream := TMemoryStream.Create;
Expand All @@ -200,7 +200,6 @@ destructor TEETSigner.Destroy;
Active := False;
FPFXStream.Free;
FCERTrustedList.Free;
Dec(EETSignerCount);
ShutDownXMLSec;
inherited;
end;
Expand Down Expand Up @@ -320,38 +319,45 @@ function TEETSigner.GetRawCertDataAsBase64String: String;

procedure TEETSigner.InitXMLSec;
begin
if EETSignerCount > 1 then
Exit;
Lock.Enter;
try
if EETSignerCount = 0 then
begin
{$IFNDEF USE_LIBEET}
xmlInitParser();
__xmlLoadExtDtdDefaultValue^ := XML_DETECT_IDS or XML_COMPLETE_ATTRS;
xmlSubstituteEntitiesDefault(1);
__xmlIndentTreeOutput^ := 0; // don't format XML elements
xmlInitParser();
__xmlLoadExtDtdDefaultValue^ := XML_DETECT_IDS or XML_COMPLETE_ATTRS;
xmlSubstituteEntitiesDefault(1);
__xmlIndentTreeOutput^ := 0; // don't format XML elements

xmlSecBase64SetDefaultLineSize(0); // for single line SignatureValue
xmlSecBase64SetDefaultLineSize(0); // for single line SignatureValue

if (xmlSecInit() < 0) then
raise EEETSignerException.Create(sSignerXmlSecInitError);
if (xmlSecInit() < 0) then
raise EEETSignerException.Create(sSignerXmlSecInitError);

if (xmlSecCheckVersionExt(1, 2, 18, xmlSecCheckVersionABICompatible) <> 1) then
raise EEETSignerException.Create(sSignerInitWrongDll);
if (xmlSecCheckVersionExt(1, 2, 18, xmlSecCheckVersionABICompatible) <> 1) then
raise EEETSignerException.Create(sSignerInitWrongDll);

if (xmlSecCryptoDLLoadLibrary('openssl') < 0) then
raise EEETSignerException.Create(sSignerInitNoXmlsecOpensslDll);
// if (xmlSecCryptoDLLoadLibrary('mscrypto') < 0)
// then raise EEETSignerException.Create(sSignerInitNoXmlsecMSCryptoDll);
if (xmlSecCryptoDLLoadLibrary('openssl') < 0) then
raise EEETSignerException.Create(sSignerInitNoXmlsecOpensslDll);
// if (xmlSecCryptoDLLoadLibrary('mscrypto') < 0)
// then raise EEETSignerException.Create(sSignerInitNoXmlsecMSCryptoDll);

if (xmlSecCryptoAppInit(nil) < 0) then
raise EEETSignerException.Create(sSignerXmlSecInitError);
if (xmlSecCryptoAppInit(nil) < 0) then
raise EEETSignerException.Create(sSignerXmlSecInitError);

if (xmlSecCryptoInit() < 0) then
raise EEETSignerException.Create(sSignerXmlSecInitError);
if (xmlSecCryptoInit() < 0) then
raise EEETSignerException.Create(sSignerXmlSecInitError);
{$ELSE}
if not InitLibEETSigner('') then
raise EEETSignerException.Create(sSignerLibEETInitLibError);
if (eetSignerInit < 0) then
raise EEETSignerException.Create(sSignerLibEETSignerInitError);
if not InitLibEETSigner('') then
raise EEETSignerException.Create(sSignerLibEETInitLibError);
if (eetSignerInit < 0) then
raise EEETSignerException.Create(sSignerLibEETSignerInitError);
{$ENDIF}
end;
Inc(EETSignerCount);
finally
Lock.Leave;
end;
end;

procedure TEETSigner.LoadPFXCertFromFile(const PFXFileName: TFileName; const CertPassword: AnsiString);
Expand Down Expand Up @@ -877,7 +883,7 @@ procedure TEETSigner.SetActive(const Value: Boolean);
eetSignerKeysMngrDestroy(FMngr);
FMngr := nil;
end;
eetSignerCleanUp;
// eetSignerCleanUp;
{$ENDIF}
FPFXStream.Clear;
FCERTrustedList.Clear;
Expand Down Expand Up @@ -994,7 +1000,7 @@ procedure TEETSigner.SetActive(const Value: Boolean);
eetSignerKeysMngrDestroy(FMngr);
FMngr := nil;
end;
eetSignerCleanUp;
// eetSignerCleanUp;
{$ENDIF}
raise;
end;
Expand All @@ -1007,16 +1013,23 @@ procedure TEETSigner.SetActive(const Value: Boolean);

procedure TEETSigner.ShutDownXMLSec;
begin
if EETSignerCount = 0 then
begin
Lock.Enter;
try
if EETSignerCount > 0 then
Dec(EETSignerCount);
if EETSignerCount = 0 then
begin
{$IFNDEF USE_LIBEET}
xmlSecCryptoShutdown();
xmlSecCryptoAppShutdown();
xmlSecShutdown();
xmlSecCryptoShutdown();
xmlSecCryptoAppShutdown();
xmlSecShutdown();
{$ELSE}
eetSignerShutdown;
eetSignerShutdown;
{$ENDIF}
end;
end;
finally
Lock.Leave;
end;
end;

function TEETSigner.SignString(const s: string): AnsiString;
Expand Down Expand Up @@ -1320,4 +1333,10 @@ procedure TCERTrustedList.Notify(Ptr: Pointer; Action: TListNotification);
TMemoryStream(Ptr).Free;
end;

initialization
Lock := TCriticalSection.Create;

finalization
Lock.Free;

end.
1 change: 0 additions & 1 deletion source/eet/u_libeet.pas
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ function libeetErrorsGetMsg(pos: xmlSecSize) : string;
if buf <> nil then
begin
Result := string(buf);
eetFree(buf);
end;
end;

Expand Down
8 changes: 4 additions & 4 deletions source/vcruntime/vcruntime.pas
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ interface

const
{$IFDEF USE_LIBEET}
// LIBMSVCRT = 'ucrtbase.dll'; // Visual Studio 2015 and higher
LIBMSVCRT = 'msvcr120.dll'; // Visual Studio 2013
LIBMSVCRT = 'ucrtbase.dll'; // Visual Studio 2015 and higher
// LIBMSVCRT = 'msvcr120.dll'; // Visual Studio 2013
{$ELSE}
{$IFDEF USE_VS_LIBS}
LIBMSVCRT = 'msvcr120.dll'; // Visual Studio 2013
// LIBMSVCRT = 'ucrtbase.dll'; // Visual Studio 2015 and higher
// LIBMSVCRT = 'msvcr120.dll'; // Visual Studio 2013
LIBMSVCRT = 'ucrtbase.dll'; // Visual Studio 2015 and higher
{$ELSE}
LIBMSVCRT = 'msvcrt.dll'; // MinGW32 libs
{$ENDIF}
Expand Down

0 comments on commit 0d240c6

Please sign in to comment.