【发布时间】:2015-04-12 02:25:22
【问题描述】:
我想验证证书密码。目前我有基于处理 CryptographicException 和检查异常消息的代码。但这种方法依赖于英语文化信息。
public bool VerifyPassword(byte[] fileContent, string password)
{
try
{
var certificate = new X509Certificate2(fileContent, password);
}
catch (CryptographicException ex)
{
if (ex.Message.StartsWith("The specified network password is not correct."))
{
return false;
}
throw;
}
return true;
}
我一直在寻找如何验证证书密码的其他解决方案,但没有成功。
验证证书密码的正确方法是什么?
我会很感激任何想法...
【问题讨论】:
标签: .net exception-handling certificate x509certificate2