我需要对一个ClickOnce应用程序进行修改,但已经有一年没有接触过它了,因此证书已过期。
我已经了解到使用新证书发布将导致应用程序失败,因为它将由不同的密钥签名。
因此,我认为我需要使用相同的证书,但不确定如何更新它。
我需要对一个ClickOnce应用程序进行修改,但已经有一年没有接触过它了,因此证书已过期。
我已经了解到使用新证书发布将导致应用程序失败,因为它将由不同的密钥签名。
因此,我认为我需要使用相同的证书,但不确定如何更新它。
更新:@OceanAirdrop已经完成以下所有工作,并将其放在github上提供:https://github.com/OceanAirdrop/ExtendClickOnceCertificate,他在readme登陆页面上有使用说明。
原始详细信息:
如@Andy Blackman所述,更新pfx是正确的方法,但是renewcert在我尝试使用它时在现代windows上运行时存在问题。为了解决may.be/renewcert依赖关系,另一位开发者用C#重写了它,因此您可以在现代Visual Studio上使用它:
https://nathanpjones.com/2013/01/renewing-temporary-certificate/
从该网站下载源代码,进行编译和运行。
如果在CertNameToStr的wcslen封送中出现“system.accessviolationexception”错误,则进行以下更改,以便封送不会崩溃:
In Crypt.cs:Line 130 change the psz variable to use char[] instead of string:
[DllImport("crypt32.dll", CharSet = CharSet.Auto)]
- internal static extern int CertNameToStr(X509Encoding dwCertEncodingType, ref CRYPT_DATA_BLOB pName, CertNameType dwStrType, ref string psz, int csz);
+ internal static extern int CertNameToStr(X509Encoding dwCertEncodingType, ref CRYPT_DATA_BLOB pName, CertNameType dwStrType, [In, Out] char[] psz, int csz);
In Program.cs:Line 131 use a char buffer instead of a string:
- //var buffer = new char[1024];
- string buffer = new string('\0', 1024);
+ char[] buffer = new char[1024];
+ //string buffer = new string('\0', 1024);
int d;
- if ((d = Crypt.CertNameToStr(Crypt.X509Encoding.ASN_Encodings, ref certNameBlob, Crypt.CertNameType.CERT_X500_NAME_STR, ref buffer, 1024 * sizeof(char))) != 0)
+ if ((d = Crypt.CertNameToStr(Crypt.X509Encoding.ASN_Encodings, ref certNameBlob, Crypt.CertNameType.CERT_X500_NAME_STR, buffer, 1024 * sizeof(char))) != 0)
如果只需快速更新默认五年的证书,请使用以下命令:
"[path-to-renew-cert-proj-dir\bin\Debug\]renewCert.exe" [old-cert-path\]old_cert_name.pfx [new-cert-path\]new_cert_name.pfx
如果我没记错的话,我遇到了同样的问题,并创建了一个新的证书。
我想自动更新在这些版本之间出了问题,但没有造成持久性的损害。可能有所帮助的是,我的应用程序仅供内部使用,所以我不需要一个正式签名的证书。
基本上,您需要构建一个应用程序来延长证书的有效期。上面的链接将带您进入该应用程序的C++源代码。如果您很幸运,只是自己签名,它可能会起作用。如果您使用了Verisign等进行签名,则需要卸载并重新安装每个应用程序。这就像您买了一辆新车,发动机爆炸了,制造商给您一本关于重新构建引擎而不是更换或修复它的书。ClickOnce不是。