如何给ActiveX控件签名?

解决方案 »

  1.   

    下载CABSDK
    以下:
    创建PVK文件[私人密匙文件]makecert -sk DigitalTitan DigitalTitan.pvk
    makecert -n CN=TelStar TelStar创建CER文件[公司证书]makecert -sk DigitalTitan.pvk TelStar.cer创建SPC测试软件出版商证明书cert2spc root.cer TelStar.cer TelStar.spc创建INF文件[version]
    signature="$CHINA$"
    AdvancedINF=2.0[Add.Code]
    WebOffice.ocx=WebOffice.ocx
    mfc70.dll=mfc70.dll
    msvcrt.dll=msvcrt.dll
    olepro32.dll=olepro32.dll[mfc70.dll]
    file-win32-x86=thiscab
    FileVersion=7,0,9466,0
    DestDir=11
    RegisterServer=yes[msvcrt.dll]
    file-win32-x86=thiscab
    FileVersion=6,1,9844,0
    DestDir=11
    RegisterServer=yes[olepro32.dll]
    file-win32-x86=thiscab
    FileVersion=5,0,4522,0
    DestDir=11
    RegisterServer=yes[WebOffice.ocx]
    file-win32-x86=http://10.70.151.253:9003/ActiveX/WebOffice.cab
    clsid={05430EC0-69CA-437A-B1F9-4B78B8647BEA} 
    FileVersion=1,0,0,1
    RegisterServer=yes
    ;创建CAB文件
    cabarc -s 6144 n WebOffice.cab mfc70.dll msvcrt.dll olepro32.dll WebOffice.ocx WebOffice.inf使用Code Signing Wizard签署一个CAB文件
    SIGNCODE.exe
    另:
    makeCert -sk DigitalTitanKey -n "CN=TelStar" -ss TelStar TelStar.cer
    makecert -is TelStar -ic TelStar.cer -ss TelStarCompany.cerCert2SPC MyCert.cer MyCert.spc
      

  2.   

    1、 创建一个自己的证书文件:
    makecert /sv "Sample_Atx.pvk" /n "CN=中软信息安全实验室" Sample_Atx.cer
    这里,Sample_Atx.pvk表示新创建的私人密钥保存文件名
    ”中软信息安全实验室”是你想显示的公司名
    Sample_Atx.cer是你创建最后的证书文件名
    这些根据你自己的要求填写,最后得到Sample_Atx.pvk和Sample_Atx.cer两个文件。
    其中,运行过程中需要输入私人密钥的保护密码,一定要输入一致,不要出错。
    2、 转换cer格式为spc格式(可以省略):
    cert2spc Sample_Atx.cer Sample_Atx.spc
    得到Sample_Atx.spc文件。
    3、 创建Sample_Atx.inf文件:如下格式
    [version]
       signature="$CHICAGO$"
       AdvancedINF=2.0
    [Add.Code]
       Sample_Atx.ocx=Sample_Atx.ocx
       msvcrt.dll=msvcrt.dll
       mfc42.dll=mfc42.dll
       olepro32.dll=olepro32.dll
    [Cert_Atx.ocx]
       file-win32-x86=thiscab
       clsid={75486221-8862-400C-9A34-3D6B449ABFF2}
       FileVersion=1,0,0,0
       RegisterServer=yes
    [msvcrt.dll]
       FileVersion=4,20,0,6164
       hook=mfc42installer
    [mfc42.dll]
       FileVersion=4,2,0,6256
       hook=mfc42installer
    [olepro32.dll]
       FileVersion=4,2,0,6068
       hook=mfc42installer
    [mfc42installer]
       file-win32-x86=http://activex.microsoft.com/controls/vc/mfc42.cab
       run=%EXTRACT_DIR%\mfc42.exe
    该INF指定了需要安装的版本的Sample_Atx.ocx。"thiscab" 是一个关键字,意指包含该INF的CAB文件。其他的DLL文件,是该Sample_Atx.ocx发布时要使用的动态连接库,您也可以从网上下载所需要的DLL文件,只要指定一个HTTP网址即可,绝对路径或者相对路径都可以,比如: file-win32-x86=http://activex.microsoft.com/controls/vc/mfc42.cab,关键字"file-win32-x86" 指定平台是 x86。 
    得到一个文件的版本号的过程是:在Windows NT或者Windows 95 Explorer中右键点击该文件;从弹出列表中选择Properties,然后在接着弹出的对话框中选择版本标签。有时,您可能需要在文件版本中插入一个额外的0 。比如,对话框中显示ATL.DLL的版本号是2.00.7024,在INF文件中则变为2,00,0,7024 。
    "clsid" 指的是要安装控件的CLSID。
    4、 然后用命令cabarc n Sample_Atx.cab Sample_Atx.inf Sample_Atx.ocx,将Sample_Atx.ocx和Sample_Atx.inf打包到Sample_Atx.cab
    5、 用chktrust检查是否正确
    chktrust -v Sample_Atx.cab
    6、 使用signcode按向导要求对cab文件签名,在选择签名类型时使用“自定义”,选择证书时,使用“从文件选择”。
    7、 将签名后的cab文件和相应的htm文件拷贝到代理服务器的地址下
    这样你就可以发布了
      

  3.   

    我找不到makecert 文件呀!
    不要第一第二步可以不?
      

  4.   

    PackageForTheWeb工具打包会给你签名的
      

  5.   

    哪里找makecert 这个东东呀?我找不到VC5的安装盘呀!
      

  6.   

    你把微软sdk下载安装,在bin下就有
      

  7.   

    没有呀,只有CABARC.ext,EXTRACT.ext,MAKECAB.exe呀
      

  8.   

    Digital Code Signing Step-by-Step Guidehttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsmarttag/html/odc_dcss.asp
      

  9.   

    还想问一句!就是inf文件中的DestDir该写什么?那把那些dll如msvcrt.dll放到哪里去?是不是放到一个与ocx文件一个文件夹,然后一起打包吗?
      

  10.   

    主要是这个ActiveX要在网页上使用才行呀!分不够可以再给
      

  11.   

    >就是inf文件中的DestDir该写什么?Next is the DestDir key. The value of this key tells Internet Explorer to which directory to download the DLL. If you specify a value of 10, the DLL is downloaded to the \Windows or \WinNT directory. If you specify a value of 11, the DLL is downloaded to the \Windows\System or \WinNT\System32 directory. If no value is specified, the DLL is downloaded to the Downloaded Program Files directory in either \Windows or \WinNT. In the case of SimpleCtrl.dll, we didn't specify a value for DestDir, so the DLL will be downloaded to the Downloaded Program Files directory.