I want to use RSACryptoServiceProvider class in to secure the
attachments in DIME messages.
The following is my sample code snippet:
client:
......
X509SecurityToken clientToken =
GetX509Token(serverCertificateKeyID,clientStoreID);
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
rsa.FromXmlString(clientToken.Certificate.PublicKey.ToXmlString(false));
byte[] cipherbytes= rsa.Encrypt(plainbytes,true);
......
the client side code just works fine.
server:
X509SecurityToken clientToken =
GetX509Token(serverCertificateKeyID,serverStoreID);
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
rsa.FromXmlString(clientToken.Certificate.Key.ToXmlString(true));
rsa.Decrypt(cipherbytes,true);
......
when the statement "clientToken.Certificate.Key.ToXmlString(true)" is
excuted , the runtime throws a exception "Export of private parameters
is not supported", I want to know how to solve the problem.
Thanks!
xiaobaoer@gmail.com - 24 Aug 2005 16:08 GMT
have you tried to just add secure token in Soap response context? I
haven't tried myself, but I assume it may just encrypt the attachment
as well.
anyway, back to your question, based on the error message you are
getting, it seems to me that the certificate you are using does not
support exporting, again I didn't try to do the same, but I remember
when you generated a certificate or importing a certificate, there's an
option to make the certificate's private key to be exportable or
something like that. you may want to make sure that's enabled.
Andy Liu - 25 Aug 2005 04:26 GMT
HI xiaoba
Thanks for your reply!
I think WSE2.0 does not support automatically encrypting the DIME
attachment.
Some posts related to the DIME attachments encryption:
http://groups.google.com/group/microsoft.public.dotnet.framework.webservices.enh
ancements/browse_thread/thread/4b2a392c49352634/9bfb3f9c526c365a?q=encrypt+++DIM
E&rnum=3&hl=zh-CN#9bfb3f9c526c365a
http://groups.google.com/group/microsoft.public.dotnet.framework.webservices.enh
ancements/browse_thread/thread/8bda9f263089c058/496bc162d4e2fd2c?q=encrypt+++DIM
E&rnum=2&hl=zh-CN#496bc162d4e2fd2c
http://groups.google.com/group/microsoft.public.dotnet.framework.webservices.enh
ancements/browse_thread/thread/e7b110e334ae1a25/5bdd4f1d77158aee?q=encrypt+++DIM
E&rnum=6&hl=zh-CN#5bdd4f1d77158aee
I used the Makecert tool to generate the certificate which does support
exporting and successfully exported the private key with the
certificate to a PKCS #12 file. But it still does not work.
Andy Liu - 25 Aug 2005 05:02 GMT
HI xiaoba
Thanks for your reply!
I think WSE2.0 does not support automatically encrypting the DIME
attachment.
Some posts related to the DIME attachments encryption:
http://groups.google.com/group/microsoft.public.dotnet.framework.webservices.enh
ancements/browse_thread/thread/4b2a392c49352634/9bfb3f9c526c365a?q=encrypt+++DIM
E&rnum=3&hl=zh-CN#9bfb3f9c526c365a
http://groups.google.com/group/microsoft.public.dotnet.framework.webservices.enh
ancements/browse_thread/thread/8bda9f263089c058/496bc162d4e2fd2c?q=encrypt+++DIM
E&rnum=2&hl=zh-CN#496bc162d4e2fd2c
http://groups.google.com/group/microsoft.public.dotnet.framework.webservices.enh
ancements/browse_thread/thread/e7b110e334ae1a25/5bdd4f1d77158aee?q=encrypt+++DIM
E&rnum=6&hl=zh-CN#5bdd4f1d77158aee
I used the Makecert tool to generate the certificate which does support
exporting and successfully exported the private key with the
certificate to a PKCS #12 file. But it still does not work.