如何获取控制台应用程序的数字签名?

时间:2015-03-04 03:46:45

标签: c++ certificate digital-signature code-signing

我制作了一个简单的控制台应用程序来播放系统哔声中的马里奥主题曲。我正在运行Windows 7,当程序运行时,它会发出一条警告,说明"发布者未经过验证"。这种情况也发生在Windows 8上,它说" Windows智能屏幕阻止了无法识别的应用程序启动"。如何获取数字签名并将其链接到控制台应用程序,以便此错误停止?

源代码:

#include <Windows.h>

int main()
{
    Beep (330,100);Sleep(100);
    Beep (330,100);Sleep(300);
    Beep (330,100);Sleep(300);
    Beep (262,100);Sleep(100);
    Beep (330,100);Sleep(300);
    Beep (392,100);Sleep(700);
    Beep (196,100);Sleep(700);
    Beep (262,300);Sleep(300);
    Beep (196,300);Sleep(300);
    Beep (164,300);Sleep(300);
    Beep (220,300);Sleep(100);
    Beep (246,100);Sleep(300);
    Beep (233,200);
    Beep (220,100);Sleep(300);
    Beep (196,100);Sleep(150);
    Beep (330,100);Sleep(150);
    Beep (392,100);Sleep(150);
    Beep (440,100);Sleep(300);
    Beep (349,100);Sleep(100);
    Beep (392,100);Sleep(300);
    Beep (330,100);Sleep(300);
    Beep (262,100);Sleep(100);
    Beep (294,100);Sleep(100);
    Beep (247,100);Sleep(500);
    Beep (262,300);Sleep(300);
    Beep (196,300);Sleep(300);
    Beep (164,300);Sleep(300);
    Beep (220,300);Sleep(100);
    Beep (246,100);Sleep(300);
    Beep (233,200);
    Beep (220,100);Sleep(300);
    Beep (196,100);Sleep(150);
    Beep (330,100);Sleep(150);
    Beep (392,100);Sleep(150);
    Beep (440,100);Sleep(300);
    Beep (349,100);Sleep(100);
    Beep (392,100);Sleep(300);
    Beep (330,100);Sleep(300);
    Beep (262,100);Sleep(100);
    Beep (294,100);Sleep(100);
    Beep (247,100);Sleep(900);
    Beep (392,100);Sleep(100);
    Beep (370,100);Sleep(100);
    Beep (349,100);Sleep(100);
    Beep (311,100);Sleep(300);
    Beep (330,100);Sleep(300);
    Beep (207,100);Sleep(100);
    Beep (220,100);Sleep(100);
    Beep (262,100);Sleep(300);
    Beep (220,100);Sleep(100);
    Beep (262,100);Sleep(100);
    Beep (294,100);Sleep(500);
    Beep (392,100);Sleep(100);
    Beep (370,100);Sleep(100);
    Beep (349,100);Sleep(100);
    Beep (311,100);Sleep(300);
    Beep (330,100);Sleep(300);
    Beep (523,100);Sleep(300);
    Beep (523,100);Sleep(100);
    Beep (523,100);Sleep(1100);
    Beep (392,100);Sleep(100);
    Beep (370,100);Sleep(100);
    Beep (349,100);Sleep(100);
    Beep (311,100);Sleep(300);
    Beep (330,100);Sleep(300);
    Beep (207,100);Sleep(100);
    Beep (220,100);Sleep(100);
    Beep (262,100);Sleep(300);
    Beep (220,100);Sleep(100);
    Beep (262,100);Sleep(100);
    Beep (294,100);Sleep(500);
    Beep (311,300);Sleep(300);
    Beep (296,300);Sleep(300);
    Beep (262,300);Sleep(1300);
    Beep (262,100);Sleep(100);
    Beep (262,100);Sleep(300);
    Beep (262,100);Sleep(300);
    Beep (262,100);Sleep(100);
    Beep (294,100);Sleep(300);
    Beep (330,200);Sleep(50);
    Beep (262,200);Sleep(50);
    Beep (220,200);Sleep(50);
    Beep (196,100);Sleep(700);
    Beep (262,100);Sleep(100);
    Beep (262,100);Sleep(300);
    Beep (262,100);Sleep(300);
    Beep (262,100);Sleep(100);
    Beep (294,100);Sleep(100);
    Beep (330,100);Sleep(700);
    Beep (440,100);Sleep(300);
    Beep (392,100);Sleep(500);
    Beep (262,100);Sleep(100);
    Beep (262,100);Sleep(300);
    Beep (262,100);Sleep(300);
    Beep (262,100);Sleep(100);
    Beep (294,100);Sleep(300);
    Beep (330,200);Sleep(50);
    Beep (262,200);Sleep(50);
    Beep (220,200);Sleep(50);
    Beep (196,100);Sleep(700);

    // Intro
    Beep (330,100);Sleep(100);
    Beep (330,100);Sleep(300);
    Beep (330,100);Sleep(300);
    Beep (262,100);Sleep(100);
    Beep (330,100);Sleep(300);
    Beep (392,100);Sleep(700);
    Beep (196,100);Sleep(700);
    Beep (196,100);Sleep(125);
    Beep (262,100);Sleep(125);
    Beep (330,100);Sleep(125);
    Beep (392,100);Sleep(125);
    Beep (523,100);Sleep(125);
    Beep (660,100);Sleep(125);
    Beep (784,100);Sleep(575);
    Beep (660,100);Sleep(575);
    Beep (207,100);Sleep(125);
    Beep (262,100);Sleep(125);
    Beep (311,100);Sleep(125);
    Beep (415,100);Sleep(125);
    Beep (523,100);Sleep(125);
    Beep (622,100);Sleep(125);
    Beep (830,100);Sleep(575);
    Beep (622,100);Sleep(575);
    Beep (233,100);Sleep(125);
    Beep (294,100);Sleep(125);
    Beep (349,100);Sleep(125);
    Beep (466,100);Sleep(125);
    Beep (587,100);Sleep(125);
    Beep (698,100);Sleep(125);
    Beep (932,100);Sleep(575);
    Beep (932,100);Sleep(125);
    Beep (932,100);Sleep(125);
    Beep (932,100);Sleep(125);
    Beep (1046,675);

    system("pause");
    return 0;
}

如果需要测试应用程序,可以在此处找到:Mario System Beeps.exe

病毒扫描(适用于所有PC Hypochondriacs):Mario System Beeps.exe Virus Scan

1 个答案:

答案 0 :(得分:0)

您需要使用代码签名证书签署您的申请。看看this blog post(来自Hanselman),它解释了如何做到这一点。它并不完全适用于控制台应用程序,但原理是相同的(使用codesign进行签名并添加时间戳)。

在大多数情况下,您需要购买代码签名证书,但有CA(即如果您是开源开发人员),您可以免费获得它。其中一个是Cetrum CA(我目前正在使用)。看看here。获得它的过程是一种折磨,但证书本身是可以的。 (它不适用于所有浏览器 - 使用FF,需要在每个页面上完成单点登录,而邮件则使用波兰语。)

可以免费获取时间戳(即从Hanselmans博客中的链接获取,或者您可以找到符合RFC 3161的免费时间戳权限列表here