Discuss this help topic in SecureBlackbox Forum
Creating ASiC-S containers
Three steps necessary to create a new ASiC-S container:
The result of running the sample code below is a ZIP archive containing:
// ASiC-S example (Pascal code)
Container := TElASiCContainer.Create(nil);
Container.CreateContainer;
Container.SignatureForm := asfSimple;
Container.Add('C:\Documents\sample.txt');
// Adding a timestamp. First initialize a TSP client, here we use TElHTTPTSPClient.
HTTPClient := TElHTTPSClient.Create(nil);
HTTPClient.OnCertificateValidate := DoCertificateValidate;
Timestamper := TElHTTPTSPClient.Create(nil);
Timestamper.HTTPClient := HTTPClient;
Timestamper.URL := 'http://time.certum.pl/';
Container.AddTimestamp(Timestamper);
// Add a CAdES signature; load a certificate first.
Certificate := TElX509Certificate.Create(nil);
Certificate.LoadFromFileAuto('C:\Documents\cert.pfx', 'password');
CadesSig := Container.AddCAdESSignature;
CadesSig.AddSignatureEntry(Certificate, nil);
// Add a XAdES signature; use the same certificate.
XadesSig := Container.AddXAdESSignature(Certificate);
// We can add multiple signature entries to XAdES signature document.
Certificate2 := TElX509Certificate.Create(nil);
Certificate2.LoadFromFileAuto('C:\Documents\cert2.pfx', 'password');
index := XadesSig.AddSignatureEntry(Certificate2);
// in this case we should also point to the signed entry
XadesSig.SignatureEntries[index].AddReference(Container.ASiCSSignedEntry);
// Save the archive calculating all timestamps and signatures.
Container.Compress('C:\Documents\sample.asics');