.net从X509签名文件中提取时间戳信息

时间:2016-04-06 10:18:25

标签: c# .net signing

我要从数字签名文件中提取信息。

我已成功解码并从文件文件中提取信息,但我无法找到如何提取该文件的时间戳信息

我尝试过.net类SignedCms或BouncyCastle,但我无法想象如何成功读取所请求的信息。

工作代码可能是这样的:

SignedCms sc = new SignedCms();
sc.Decode(System.IO.File.ReadAllBytes(file);
var sinfo = sc.SignerInfos[0];

// the search!!!
foreach (var unsignedAttribute in sinfo.UnsignedAttributes)
{
    foreach (var value in unsignedAttribute.Values)
    {
        System.Diagnostics.Debug.WriteLine(String.Format("{0}, {1}", unsignedAttribute.Oid.Value, value.Oid.Value));
        switch (value.Oid.Value)
        {
            // Search TSA information
            case "1.2.840.113549.1.9.16.2.14":
                readTimeStamp = new EATimeStamp();
                Pkcs9AttributeObject attributeObject = value as Pkcs9AttributeObject;
                // The TSA information are in this attribute rawdata
                SignedCms scms = new SignedCms();
                scms.Decode(attributeObject.RawData);
                scms.CheckSignature(true);
                // HERE I NEED TO FIND DATA OF ATTRIBUTES 
                readTimeStamp.GetSerialNum = "da estrarre";
                readTimeStamp.GetPolicyID = "da estrarre";
                readTimeStamp.GenDate = "da estrarre";
                // here there are the timestamp certification autority,
                if (scms.SignerInfos != null && scms.SignerInfos.Count > 0)
                {
                    readTimeStamp.GetSigner = EASignerInfo.Create(scms.SignerInfos[0]);
                }

                break;
            default:
                break;
        }
    }

}

0 个答案:

没有答案