Example #1
0
        public Asn1EncodableVector GetTimestamp(byte[] signature)
        {
            var conf = Config.Timestamp;
            var tsc = new TSAClientEx(conf.Url, conf.Username, conf.Password);
            tsc.ProxyAddress = conf.ProxyAddress;
            tsc.ProxyPassword = conf.ProxyPassword;
            tsc.ProxyUsername = conf.ProxyUsername;

            byte[] tsImprint = PdfEncryption.DigestComputeHash("SHA1", signature);

            //ITSAClient tsc = new TSAClientBouncyCastle("http://tsa.net", null, null);
            //return tsc.GetTimeStampToken(null, tsImprint);
            String ID_TIME_STAMP_TOKEN = "1.2.840.113549.1.9.16.2.14"; // RFC 3161 id-aa-timeStampToken

            Asn1InputStream tempstream = new Asn1InputStream(new MemoryStream(tsc.GetTimeStampToken(tsImprint)));

            Asn1EncodableVector unauthAttributes = new Asn1EncodableVector();

            Asn1EncodableVector v = new Asn1EncodableVector();
            v.Add(new DerObjectIdentifier(ID_TIME_STAMP_TOKEN)); // id-aa-timeStampToken
            Asn1Sequence seq = (Asn1Sequence)tempstream.ReadObject();
            v.Add(new DerSet(seq));

            unauthAttributes.Add(new DerSequence(v));
            return unauthAttributes;
        }
Example #2
0
 protected ITSAClient GetTsaClient()
 {
     var tsa = config.Timestamp;
     var tsc = new TSAClientEx(tsa.Url, tsa.Username, tsa.Password);
     if (!string.IsNullOrEmpty(tsa.ProxyAddress)) {
         tsc.ProxyAddress = tsa.ProxyAddress;
         tsc.ProxyUsername = tsa.ProxyUsername;
         tsc.ProxyPassword = tsa.ProxyPassword;
     }
     return tsc;
 }