我正在使用RSACryptoServiceProvider來提高安全性。如何使用指紋來保證安全?
我使用自簽名證書構建了代碼以用於測試目的。 不是用戶向我們提供了實際的指紋。 我期待取得證書嗎? 如何使用指紋?
這裏是代碼:
/// Builds Authorization in using self signed certificate
/// </summary>
/// <returns></returns>
private string BuildAuthorization()
{
X509Certificate2 cert = GetCertificate();
RSACryptoServiceProvider provideEncryptor = (RSACryptoServiceProvider)cert.PublicKey.Key;
string authorizaionValue = string.Format("{0}:{1}:{2}", _userName,_password, _currentTime);
byte[] encryptedData = provideEncryptor.Encrypt(Encoding.UTF8.GetBytes(authorizaionValue), false);
string encryptedString = Convert.ToBase64String(encryptedData);
return encryptedString;
}
/// <summary>
/// creates a self signed certificate
/// </summary>
/// <returns></returns>
private X509Certificate2 GetCertificate()
{
X509Store store = new X509Store(StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
X509Certificate2 cert = null;
string certName = ConfigurationManager.AppSettings["CertName"];
foreach (var c in store.Certificates)
{
if (c.Subject.Equals(certName, StringComparison.OrdinalIgnoreCase))
{
cert = c;
break;
}
}
store.Close();
return cert;
}
提供的指紋是一樣的東西:
87aa7f6 ******************** 9b2d95093a6
AnyOne有什麼想法是什麼意思? – grace
我找到了一個解決方案,請檢查 http://stackoverflow.com/questions/11115511/how-to-find-certificate-by-its-thumbprint-in-c-sharp – Nazmul