ClickOnce 배포 매니페스트를 동적으로 생성하고 서명하는 데 사용하고있는 Thawte의 코드 서명 인증서가 있습니다. 문제는 우리가 IIS 또는 다시 가져 서명 인증서를 다시 시작할 때 생성 흔적이 매니페스트 ASP.NET 응용 프로그램이 잘 작동하지만, 시간이 지남에 따라 다음과 같은 기능은 인증서 찾는데 실패 : 결국시간이 지남에 따라 ASP.NET 응용 프로그램에서 사라지는 인증서 저장소에 인증서가 저장되었습니다.
private static X509Certificate2 GetSigningCertificate(string thumbprint)
{
X509Store x509Store = new X509Store(StoreLocation.CurrentUser);
try
{
x509Store.Open(OpenFlags.ReadOnly);
X509Certificate2Collection x509Certificate2Collection = x509Store.Certificates.Find(
X509FindType.FindByThumbprint, thumbprint, false);
if (x509Certificate2Collection.Count == 0)
throw new ApplicationException(
"SigningThumbprint returned 0 results. Does the code signing certificate exist in the personal store?",
null);
if (x509Certificate2Collection.Count > 1)
throw new ApplicationException(
"SigningThumbprint returned more than 1 result. This isn't possible", null);
var retval = x509Certificate2Collection[0];
if(retval.PrivateKey.GetType() != typeof(RSACryptoServiceProvider))
throw new ApplicationException("Only RSA certificates are allowed for code signing");
return retval;
}
finally
{
x509Store.Close();
}
}
을 응용 프로그램이 인증서를 찾을 수없는 오류를 던지기 시작합니다. 왜냐하면 우리가 ASP.NET 응용 프로그램을 시작할 때 인증서를 찾지 만 인증서가 올바르게 설치되었다고 생각하기 때문입니다. 그러나 어떤 시점에서는 Count == 0 분기를 맞추기 만하면됩니다. 인증서는 응용 프로그램 풀 사용자의 "현재 사용자 \ 개인"인증서 저장소에 있습니다.
질문 : 갑자기 "갑자기 사라지거나"발견되지 않는 이유는 무엇입니까?