ASP.NETを使用して個人ストアからクライアント証明書をロードするにはどうすればよいですか?ASP.NETを使用して個人ストアからクライアント証明書をロードするにはどうすればよいですか?
可能であれば、データを暗号化できますか?
私はASP.NET 2.0でアプリケーションを作成し、クライアント証明書ストアにインストールされているすべての証明書を取得してデジタル署名を作成しました。
が、それは動作しません、と私はあなたがこのASP.NETアプリケーションをノックしている推測している問題
// ...
using System.Security.Cryptography.X509Certificates;
namespace WebApplication4
{
public partial class _Default : System.Web.UI.Page
{
public static string ToHexString(byte[] bytes)
{
// ...
}
protected void btnSignature_Click(object sender, EventArgs e)
{
X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.OpenExistingOnly);
X509Certificate2Collection certificates = store.Certificates;
int a = certificates.Count;
lbCertCount.Text = System.Convert.ToString(a);
if (a > 0)
{
X509Certificate2 certificate = certificates[1];
string publicKey = certificate.GetPublicKeyString();
lbMypublicKey.Text = publicKey + "<br/>";
// AsymmetricAlgorithm privateKey = certificate.PrivateKey;
RSACryptoServiceProvider privateKey = certificate.PrivateKey as RSACryptoServiceProvider;
// test message
byte[] buffer = Encoding.Default.GetBytes("Welcome");
byte[] signature = privateKey.SignData(buffer, new SHA1Managed());
string me = ToHexString(signature);
lbSignature.Text = me;
RSACryptoServiceProvider publicKey1 = certificate.PublicKey.Key as RSACryptoServiceProvider;
bool verify = publicKey1.VerifyData(buffer, new SHA1Managed(), signature);
if (verify == true)
{
lbControl.Text = "Signature valid";
}
else
{
lbControl.Text = "Signature not Valid";
}
}
}
}
}
サーバー上の訪問者証明書またはユーザーアカウントの証明書を読み込もうとしていますか? –
私は訪問者の証明書を読み込もうとします。注意:私のすべての訪問者はイントラネットネットワークに属し、すべてがアクティブなディレクトリに記録されています –
ユーザーをどのように認証しますか?彼らは偽装されていますか? –