是否可以对VB6应用程序进行数字签名?

是否可以对VB6应用程序进行数字签名?,vb6,digital-signature,Vb6,Digital Signature,早在2001年,我就为一家公司编写了一个VB6应用程序,现在它显然还在使用。该公司要求我对其进行数字签名,这样他们就可以避免出现“Windows保护您的电脑”对话框: 甚至可以对VB6应用程序进行数字签名吗?如果是这样的话,有人能给我指一个教程或类似的东西吗 我想这会帮助你: 简介:CAPICOM是微软推出的一项新的安全技术 允许微软 VisualBasic ,Visual Basic脚本,ASP和C++ 程序员可以轻松地将数字签名和加密集成到 它们的应用。(5页印刷) 首先,一般的答案是“

早在2001年,我就为一家公司编写了一个VB6应用程序,现在它显然还在使用。该公司要求我对其进行数字签名,这样他们就可以避免出现“Windows保护您的电脑”对话框:


甚至可以对VB6应用程序进行数字签名吗?如果是这样的话,有人能给我指一个教程或类似的东西吗

我想这会帮助你:

简介:CAPICOM是微软推出的一项新的安全技术 允许微软<强> VisualBasic ,Visual Basic脚本,ASP和C++ 程序员可以轻松地将数字签名和加密集成到 它们的应用。(5页印刷)


首先,一般的答案是“是”-VB6创建的EXE和DLL文件可以进行数字签名

我的理解是,签名过程最终会将一些“元数据”添加到签名的二进制文件中,这些文件可以在以后进行检查。这似乎是一个通用的Windows功能,而不是特定于VB6或任何其他特定的编译器(据我所知)

我用于签名的特定方法是构建步骤。这将使用PFX证书文件对二进制文件进行签名,并为其添加时间戳。(有)


请注意,我之所以使用这个工具,是因为它也是我们用于VB6构建自动化的工具(而且它工作得很好!),但我相信可以使用其他签名工具来代替它。

我们使用的是平台SDK中的
signtool.exe
,直到它停止生成sha-1签名(为了XP兼容性),所以必须迁移到开源实现(w/丑陋的cygwin依赖项)

这是我们的
codesign.bat
,我们使用它与sha-1和更新的sha-256签名同时对可执行文件进行签名。也可以对.msi再发行文件进行签名

@echo off
setlocal
set CYGWIN=nodosfilewarning
set tmpfile=%TEMP%\~$intermediate.tmp

:: set code-signing certficate .pfx file and password here
set osslsigncode="%~dp0osslsigncode.exe" sign -pkcs12 "%~dp0ucs_code_sign_current.pfx" -pass #########
set signtool="%~dp0signtool.exe" sign /f "%~dp0ucs_code_sign_current.pfx" /p ########

:: set default description and URL here (both options skipped if left empty)
set desc=
set durl=

:parse_params
if [%~1]==[] goto :parse_complete
if [%~1]==[/d] set desc="%~2"& shift /1 & shift /1 & goto :parse_params
if [%~1]==[/du] set durl="%~2"& shift /1 & shift /1 & goto :parse_params
set infile=%~1
set intype=%~x1
shift /1 & goto :parse_params
:parse_complete
if [%infile%]==[] goto :usage

if not [%desc%]==[] (
    set osslsigncode=%osslsigncode% -n %desc%
    set signtool=%signtool% /d %desc%
)
if not [%durl%]==[] (
    set osslsigncode=%osslsigncode% -i %durl%
    set signtool=%signtool% /du %durl%
)

if [%intype%]==[.msi] goto :msi_sign

%osslsigncode% -h sha1 -t http://timestamp.comodoca.com -in "%infile%" -out "%tmpfile%" > nul
if errorlevel 1 %osslsigncode% -h sha1 -t http://timestamp.globalsign.com/scripts/timestamp.dll -in "%infile%" -out "%tmpfile%" > nul
if errorlevel 1 exit /b 1
%osslsigncode% -nest -h sha2 -ts http://timestamp.comodoca.com -in "%tmpfile%" -out "%infile%" > nul
if errorlevel 1 %osslsigncode% -nest -h sha2 -ts http://timestamp.globalsign.com/?signature=sha2 -in "%tmpfile%" -out "%infile%" > nul
if errorlevel 1 exit /b 1
goto :cleanup

:msi_sign
::%signtool% /t "http://timestamp.comodoca.com" "%infile%"
::if errorlevel 1 %signtool% /t "http://timestamp.globalsign.com/scripts/timestamp.dll" "%infile%"
%osslsigncode% -h sha1 -t http://timestamp.comodoca.com -add-msi-dse -in "%infile%" -out "%tmpfile%" > nul
if errorlevel 1 %osslsigncode% -h sha1 -t http://timestamp.globalsign.com/scripts/timestamp.dll -add-msi-dse -in "%infile%" -out "%tmpfile%" > nul
if errorlevel 1 exit /b 1
copy "%tmpfile%" "%infile%" /y > nul

:cleanup
del "%tmpfile%" /q
goto :eof

:usage
echo usage: %~nx0 [options] ^<infile^>
echo.
echo where options:
echo     /d  ^<desc^>    Optional file description
echo     /du ^<url^>     Optional company URL
echo.
goto :eof
@echo关闭
setlocal
设置CYGWIN=nodosfilewarning
设置tmpfile=%TEMP%\~$intermediate.tmp
::在此处设置代码签名证书.pfx文件和密码
设置osslsigncode=“%~dp0osslsigncode.exe”符号-pkcs12”%~dp0ucs\U代码\U符号\U当前.pfx”-通过#########
set signtool=“%~dp0signtool.exe”sign/f”%~dp0ucs\u code\u sign\u current.pfx”/p########
::在此处设置默认描述和URL(如果保留为空,则跳过这两个选项)
设置描述=
集杜尔=
:parse_参数
如果[%~1]=[]转到:解析完成
如果[%~1]=[/d]设置desc=“%~2”&shift/1&shift/1&goto:parse_参数
如果[%~1]=[/du]设置durl=“%~2”&shift/1&shift/1&goto:parse_参数
集合infle=%~1
set intype=%~x1
shift/1和goto:parse_参数
:解析_完成
如果[%infle%]=[]转到:用法
如果不是[%desc%]=[](
设置osslsigncode=%osslsigncode%-n%desc%
设置signtool=%signtool%/d%desc%
)
如果不是[%durl%]=[](
设置osslsigncode=%osslsigncode%-i%durl%
设置signtool=%signtool%/du%durl%
)
如果[%intype%]==[.msi]转到:msi\u符号
%osslsigncode%-h sha1-thttp://timestamp.comodoca.com -输入“%infle%”-输出“%tmpfile%”nul
如果错误级别为1%osslsigncode%-h sha1-thttp://timestamp.globalsign.com/scripts/timestamp.dll -输入“%infle%”-输出“%tmpfile%”nul
如果错误级别1退出/b 1
%osslsigncode%-nest-h sha2-tshttp://timestamp.comodoca.com -在“%tmpfile%”中-在“%infle%”中输出nul
如果错误级别为1%osslsigncode%-嵌套-h sha2-tshttp://timestamp.globalsign.com/?signature=sha2 -在“%tmpfile%”中-在“%infle%”中输出nul
如果错误级别1退出/b 1
后藤:清理
:msi_符号
:%signtool%/t“http://timestamp.comodoca.com“%infle%”
::如果错误级别为1%signtool%/t“http://timestamp.globalsign.com/scripts/timestamp.dll“%infle%”
%osslsigncode%-h sha1-thttp://timestamp.comodoca.com -添加msi dse-in“%infle%”-out“%tmpfile%”nul
如果错误级别为1%osslsigncode%-h sha1-thttp://timestamp.globalsign.com/scripts/timestamp.dll -添加msi dse-in“%infle%”-out“%tmpfile%”nul
如果错误级别1退出/b 1
复制“%tmpfile%”%infle%/y>nul
:清理
删除“%tmpfile%”/q
后藤:eof
:用法
回显用法:%~nx0[选项]^
回声。
回显其中的选项:
echo/d^可选文件说明
echo/du^可选公司URL
回声。
后藤:eof

您需要PFX格式的商业代码签名证书。您可以根据需要调整此批处理,或将其用作IMP的灵感。

您可以对任何可执行和/或msi包进行签名(如果您将其用于部署)。搜索“代码签名”或“可执行签名”;例如,如果您使用的是Installshield,则可以对已在生成过程中的文件进行签名。StackOverflow实际上不用于将用户指向教程。但是,是的,您应该能够对由VB6创建的可执行文件进行签名,就像对任何其他可执行文件进行签名一样。我使用Inno安装程序对我的应用进行数字签名。可以手动签名,但Inno program使其变得简单和自动化。搜索Inno标记并在其中搜索代码签名。获取证书涉及到一个过程,它不是免费的,它不会消除警告对话框,它只是将您显示为“发布者”如果产品是下载的-看起来更正式。@BillHileman如果它没有消除警告对话框,那么签名有什么意义?我认为是下载的事实触发了它。如果你只是第二次运行下载的安装程序,它肯定不会,但也可能是O/s不知何故也记住了这一点我不确定以前安装的ar应用程序。我注意到,如果我通过电子邮件发送我的安装程序(当.exe和.zip没有被大多数ISP阻止时),对话框不会出现-只有当客户从我的网站下载时才会出现。