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
(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