Permition certificate private key from webservice

W

Waldek

Anybody knows how access private key X509Certificate from CertificateStore
(Microsoft.Web.Services2.Security.X509.X509CertificateStore namespace) to
encrypt/decrypt data.

Below code in webservice return error: "Keyset does not exist" (at line
includes ct.Key) ,but in desktop application is ok.
Probably problem concern security context, but how set trust for this code ?

code:


store =

Microsoft.Web.Services2.Security.X509.X509CertificateStore.LocalMachineStore
(Microsoft.Web.Services2.Security.X509.X509CertificateStore.MyStore)

'Open store
If store.OpenRead() Then
'Find some certificate
cc = store.FindCertificateBySubjectString("My Name")
If cc.Count > 0 Then
ct = cc.Item(0)
'Set private key to RSA object
Dim rsar As System.Security.Cryptography.RSA = ct.Key
rsa1 = CType(rsar,
Microsoft.Web.Services2.Security.Cryptography.RSACryptoServiceProvider)
rsa1.Encrypt ...
rsa1.Decrypt ...
end if
end if
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top