bc-csharp
bc-csharp copied to clipboard
Add Custom TSA During Digital XML Signature
Request to add Custom TSA for storing signing time during XML Signature Using https://www.nuget.org/packages/BouncyCastle/
Hi, I like to sign an XML Document. I am seeing that the signature time is taken from the system time. My concern is if the system time is not accurate, that what would happen? In that case, the time should come from a trusted TSA and the TSA should be customisable. And there should also be a TSA Url
checker so that we can find from code that if the TSA is reachable from the current network or not. This functionality should be optional because otherwise every time we need to sign a file, the internet should be needed. By default, the time should be taken from the local system, but if a TSA Url is given, then the time should be taken from the TSA.
As far as I have searched, I did not found a way of setting the
Proposed API
I like to create a signed XML like current way, but like to have a way to add a TSA Url during sign like this-
.......................
.......................
SignedXml signedXml = new SignedXml(xmlDocument);
signedXml.SigningKey = certificate.PrivateKey;
Reference reference = new Reference();
//reference.TsaUri = "http://ca.signfiles.com/TSAServer.aspx";
reference.TsaUri = "http://timestamp.globalsign.com/scripts/timstamp.dll";
//reference.TsaUri = "https://timestamp.geotrust.com/tsa"
reference.Uri = "";
reference.Id = Base64EncodedCurrentTime();
//reference.TransformChain = ;
XmlDsigEnvelopedSignatureTransform env = new XmlDsigEnvelopedSignatureTransform(true);
reference.AddTransform(env);
signedXml.AddReference(reference);
.......................
.......................
In this example reference.TsaUri
is used for signing the document.
Usage Examples
.......................................
.......................................
Reference reference = new Reference();
reference.TsaUri = "http://timestamp.globalsign.com/scripts/timstamp.dll";
.......................................
.......................................