VC ++ releases ActiveX Control Digital Signature

Source: Internet
Author: User

 
Original Author: Guangming brother

Recently I am studying ActiveX technology. I used Delphi 7 to create an ActiveX control application with activeform. This control generates a. ocx file. Now, I need to deploy this control on the server. When you browse the Web page and choose to install this control, your IE will download, install, and display this control.
 
However, my control must be digitally signed before Ie can be downloaded and installed. The problem is how to digitally sign ActiveX controls? We will share with you the specific steps.
 
First, I need a set of digital signature tools. If you do not have one, you can download it at the following address:
 
Http://files.cnblogs.com/babyt/SignTool.rar
 
The control name is custform. ocx. First, we need to create a. cab file to compress all the files to be released. The file we need to publish together is the custform. Lic file. It is generated by Delphi when we create a control project. If you do not publish this file, ie cannot display the control even if it is downloaded and installed successfully. To publish multiple files in a. cab file, we must first create a. inf file. A. inf file can tell ie where and where the files to be downloaded can be obtained.
 
1. Create a. inf file
 
It is easy to create a. inf file. You can write it in notepad. We named our. inf file gmtestx. INF. Because we need to put the gmtest. ocx and gmtest. Lic files in the. cab file, the content of our. inf file is as follows:
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[Version]
Signature = "$ Chicago $"
Advancedinf = 2.0
[Add. Code]
Custform. ocx = custform. ocx
Custform. Lic = custform. Lic // if you do not select make conctrol lincensed when creating the active form, the. Lic file will not be generated. This line can be removed when creating the. inf file.
[Custform. ocx]
File-win32-x86 = thiscab
CLSID = {C504DF79-C5EC-4314-AC3E-1F770DB81A01}
Fileversion = 1, 0, 0
Registerserver = Yes
[Custform. Lic] // if you do not select make conctrol lincensed when creating the active form, the. Lic file will not be generated. This line can be removed when you create the. inf file.
File-win32-x86 = thiscab // if you do not select make conctrol lincensed when creating an active form, the. Lic file is not generated, you can remove this line when creating the. inf file
Fileversion =, // if you do not select make conctrol lincensed when creating the active form, the. Lic file will not be generated. inf file can be removed when you create the. inf file.
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There are two codes in the [version] section of this. inf file. Signature = "$ Chicago $" indicates that this. inf file is compatible with Windows 95 or later versions and Windows NT 4.0 or later versions. Advancedinf = 2.0 indicates the version of advpack. dll. IE 4.0 or later versions must import this file to parse this. inf file. The required version is 2.0.
 
As for the [Add. Code] section, it lists the files to be downloaded in A. cab file and maps the detailed information of these files to the corresponding sections. For example, the information in [custform. ocx] is the information about downloading the custform. ocx file.
 
The first code in [custform. ocx] tells IE that the custform. ocx file is included in this. cab file. The second line indicates the CLSID of the control. The third line is the version number of the control. The fourth line tells IE to use the previous CLSID number to register the control. The [custform. Lic] section won't be discussed much.
 
2. Create a. cab file
 
Enter the following code in the command line to add the custform. ocx, custform. inf, and custform. Lic files to a. cab file named custform. Cab:
 
Cabarc.exe-s 6144 n custform. Cab custform. ocx custform. inf custform. Lic
 
3. Create a certificate file
 
Enter the following command in the command line:
 
Makecert-SV custform. PVK-r-n "cn = Sunstar" custform. Cer
 
4. Certificate conversion:
 
Cert2spc custform. Cer custform. SPC
 
5. Create another self-signed certificate named test. Cer.
 
Enter the following two commands in the command line:
 
Makecert-SV test. PVK-r-n "cn = Sunstar" test. Cer
 
Cert2spc test. Cer test. SPC
 
6. Create the test. CTL file from test. Cer.
 
Makectl test. Cer test. CTL
 
7. Use the custform. PVK and custform. SPC files to digitally sign test. CTL.
 
Signcode-V custform. PVK-SPC custform. SPC test. CTL
 
8. Move test. CTL to the storage area of the trusted system.
 
Certmgr-add-CTL test. CTL-s trust
 
9. Move custform. Cer to the root system storage zone.
 
Certmgr-add-C gmtestx. cer-s Root

10. Use test. PVK and test. SPC to digitally sign custform. Cab.
 
Singcode-V test. PVK-SPC test. SPC custform. Cab
 
11. Check whether the file has been verified
 
Chktrust custform. Cab
 
If the file passes the digital signature check, the system will ask whether to install the file. At this time, you must select the installation option to complete the signature process.
 
During the above steps, you may need to enter a password. You can select any password, such as 12345.

 

 

It is feasible for me to follow the steps above. Thanks to the bit platform, the cited blog address is:

Http://www.cnblogs.com/twttafku/archive/2009/08/25/1553389.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.