.net - Load a Certificate Using X509Certificate2 with ECC Public Key -


this newbie question. i'm trying load .der certificate using:

x509certificate2 cert = new x509certificate2(@"c:\temp\mycert.der"); rsacryptoserviceprovider csp = (rsacryptoserviceprovider)cert.publickey.key 

but "the certificate key algorithm not supported" error on 2nd line. when import certificate mmc can see public key this.

is valid? how in code?

prior .net 4.6.1 ecdsa keys not supported. legacy/compatibility reasons (such sample here you're converting rsacryptoserviceprovider) publickey.key property , x509certificate2.privatekey property still cannot ecdsa. there's instead new, more type-safe, path:

using (ecdsa ecdsa = cert.getecdsapublickey()) {     if (ecdsa != null)     {         // had in example...         bool verified = ecdsa.verifydata(data, signature, hashalgorithmname.sha256);     } } 

Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -