.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
.
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
Post a Comment