安装wse3.0using Microsoft.Web.Services3.Security.X509; private X509SecurityToken GetSigningToken() { // NOTE: If you use the WSE 3.0 sample certificates then // you should not need to change these IDs string ClientBase64KeyId = "Xt/WZcILstC8oJuMqQcxbokIGR4="; X509SecurityToken token = null; // Open the CurrentUser Certificate Store X509CertificateStore store; store = X509CertificateStore.CurrentUserStore( X509CertificateStore.MyStore ); if ( store.OpenRead() ) { X509CertificateCollection certs = store.FindCertificateByKeyIdentifier( ➥ Convert.FromBase64String( ClientBase64KeyId ) ); if (certs.Count > 0) { // Get the first certificate in the collection token = new X509SecurityToken( ((X509Certificate) certs[0]) ); } } return token; }
private X509SecurityToken GetSigningToken()
{
// NOTE: If you use the WSE 3.0 sample certificates then
// you should not need to change these IDs
string ClientBase64KeyId = "Xt/WZcILstC8oJuMqQcxbokIGR4=";
X509SecurityToken token = null;
// Open the CurrentUser Certificate Store
X509CertificateStore store;
store = X509CertificateStore.CurrentUserStore( X509CertificateStore.MyStore );
if ( store.OpenRead() )
{
X509CertificateCollection certs = store.FindCertificateByKeyIdentifier( ➥
Convert.FromBase64String( ClientBase64KeyId ) );
if (certs.Count > 0)
{
// Get the first certificate in the collection
token = new X509SecurityToken( ((X509Certificate) certs[0]) );
}
}
return token;
}
.NET 2.0中对Ceritificate以及Certificate Store的使用和管理提供了很多的类,请参看System.Security.Cryptography.X509Certificates这个命名空间。两个最常用的类是: X509Store (代表Certificate Store)和X509Certificate2 (代表X509标准的Certificates)
对不起,我们的项目是在.Net 1.1下的,所以我希望能找到一个.Net 1.1下的解决方法,谢谢你的热心回复!
我也想,可是这是公司的项目,不是我说了算的啊~
谢谢你的意见 ^_^
微软的msdn英文上有这个组件的详细用法.