Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / August 2005

Tip: Looking for answers? Try searching our database.

How to extract the private key from the X.509 Certificate(which has a corresponding private key )

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andy Liu - 24 Aug 2005 04:06 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.