Some test text!

Search
Hamburger Icon

Dotnet / Guides / Embedded timestamping

Custom Signing in C# .NET

The custom signing API also allows the creation and insertion of embedded secure (signed) timestamp tokens, which is a requirement of certain higher levels of PAdES-format signature conformance.

It is necessary to add to the VerificationOptions a trusted root certificate corresponding to the chain used by the timestamp authority to sign the timestamp token, in order for the timestamp response to be verifiable during embedded timestamp creation.

By default, we only check online for revocation of certificates using the newer and lighter OCSP protocol as opposed to CRL, due to lower resource usage and greater reliability. However, it may be necessary to enable online CRL revocation checking in order to verify some timestamps (i.e. those that do not have an OCSP responder URL for all non-trusted certificates).

TimestampingConfiguration tst_config = new TimestampingConfiguration(in_timestamp_authority_url);
VerificationOptions opts = new VerificationOptions(VerificationOptions.SignatureVerificationSecurityLevel.e_compatibility_and_archiving);
opts.AddTrustedCertificate(in_timestamp_authority_root_certificate_path);
opts.EnableOnlineCRLRevocationChecking(true);
TimestampingResult result = digsig_field.GenerateContentsWithEmbeddedTimestamp(tst_config, opts);

if (!result.GetStatus())
{
	Console.WriteLine(result.GetString());
	throw new Exception();
}
doc.SaveCustomSignature(result.GetData(), digsig_field, in_outpath);

Get the answers you need: Chat with us