Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is there a x509EncodedKeySpec / KeyFactory for C# ???

1,644 views
Skip to first unread message

rome...@gmail.com

unread,
May 19, 2009, 12:54:54 PM5/19/09
to
I am porting a Java app to C#. In my application I load a public key
from a DER file (see below):

final byte bytes[] = load( path + "/PublicKey.dat" );
X509EncodedKeySpec x509EncodedKeySpec = new
X509EncodedKeySpec( bytes );
KeyFactory keyFactory = KeyFactory.getInstance( "RSA" ,
"BC" );
publicKey = keyFactory.generatePublic
( x509EncodedKeySpec );

I can't find a way to do the same in C#. Any guidance would be
appreciated.

Thanks!

rame...@gmail.com

unread,
Aug 11, 2015, 5:57:17 PM8/11/15
to
Hi,

Please let me know if you got the solution.. I'm also facing the same issue..

Thanks

bradbury9

unread,
Aug 12, 2015, 4:40:59 AM8/12/15
to
Looking into the X509 classes I found a couple of interesting things. Not sure if it could help.

X509Certificate.CreateFromCertFile and X509Certificate.CreateFromSignedFile do return a X509Certificate.
X509Certificate has a method that return the public key bytes.
X509Certificate2 has a property to acces the public key.

https://msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509certificate.getpublickey(v=vs.110).aspx
https://msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.publickey(v=vs.110).aspx
https://msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509certificate2.publickey(v=vs.110).aspx


vvel...@webmd.net

unread,
Sep 27, 2018, 2:12:28 PM9/27/18
to
I know this is from 2009 and it is now 2018. But I have the exact same problem. Was a solution every found? Thanks in advance!

Robert Gonzales

unread,
Apr 9, 2021, 1:51:40 PM4/9/21
to
Encontraste una solucion para esto?
0 new messages