日期:2014-05-18  浏览次数:20894 次

获取文件的数字签名(包括判断微软签名和第三方签名)
获取文件的数字签名
通过判断文件是否有数字签名
如果有数字签名,读出签名人信息, 就可以判断是微软的签名还是第三方签名

非常感谢, 可以有偿报酬。。。

比较急。。

------解决方案--------------------
是指assembly吗?
------解决方案--------------------
数字签名是一串字符,无法判断签名人的信息
像这些信息不包含在数字签名中:
文件版本 : 0.0.0011
说明 : 获取文件信息
版权 : PurpleEndurer
产品版本 : 0.0.0011
产品名称 : FileInfo
公司名称 : PurpleEndurer
合法商标 : PurpleEndurer
内部名称 : FileInfo
源文件名 : FileInfo.exe
创建时间 : 2007-11-6 22:8:9
修改时间 : 2008-7-16 9:51:56
大小 : 15872 字节 15.512 KB

另外不是所有文件都包含数字签名,像txt就肯定不包含,而且不同类型文件的签名方式是不同的,像PDF和assembly就肯定不一样,我猜lz想要的是PE(就是EXE)的数字签名.

需要使用windows api来校验数字签名,可以判断文件是否有数字签名,是否通过验证,好像无法读取签名人信息:
Example C Program: Verifying the Signature of a PE File
http://msdn.microsoft.com/en-us/library/aa382384.aspx

幸运的是已经有人给翻译成C#了:
C#: Determining if a file has a valid digital signature 
http://geekswithblogs.net/robp/archive/2007/05/04/112250.aspx

good luck
------解决方案--------------------

------解决方案--------------------
至于其它文件信息,你可以使用FileVersionInfo来取得
using System.Diagnostics;

.....

FileVersionInfo info = FileVersionInfo.GetVersionInfo(@"C:\Program Files\Rational\ClearCase\bin\abe.exe");

.....
FileVersionInfo的成员:
Comments Gets the comments associated with the file. 
CompanyName Gets the name of the company that produced the file. 
FileBuildPart Gets the build number of the file. 
FileDescription Gets the description of the file. 
FileMajorPart Gets the major part of the version number. 
FileMinorPart Gets the minor part of the version number of the file. 
FileName Gets the name of the file that this instance of FileVersionInfo describes. 
FilePrivatePart Gets the file private part number. 
FileVersion Gets the file version number. 
InternalName Gets the internal name of the file, if one exists. 
IsDebug Gets a value that specifies whether the file contains debugging information or is compiled with debugging features enabled. 
IsPatched Gets a value that specifies whether the file has been modified and is not identical to the original shipping file of the same version number. 
IsPreRelease Gets a value that specifies whether the file is a development version, rather than a commercially released product. 
IsPrivateBuild Gets a value that specifies whether the file was built using standard release procedures. 
IsSpecialBuild Gets a value that specifies whether the file is a special build. 
Language Gets the default language string for the version info block. 
LegalCopyright Gets all copyright notices that apply to the specified file. 
LegalTrademarks Gets the trademarks and registered trademarks that apply to the file. 
OriginalFilename Gets the name the file was created with. 
PrivateBuild Gets information about a private version of the file. 
ProductBuildPart Gets the build number of the product this file is associated with. 
ProductMajorPart Gets the major part of the version number for the product this file is associated with. 
ProductMinorPart Gets the minor part of the version number for the product the file is associated with. 
ProductName Gets the name of the product this file is distributed with. 
ProductPrivatePart Gets the private part number of the product this file is associated with. 
ProductVersion Gets the version of the product this file is distributed with. 
SpecialBuild Gets the special build information for the file.