We need to encrypt some data and would like to do so using PKI with an elliptic curve based certificate. When we create a certificate and look at it using RSA, we get the following:
$CBytes = [byte[]](get-content -Encoding Byte -path .\RsaX509Public.cer)
$Certificate = new-object System.Security.Cryptography.X509Certificates.X509Certificate2(,$Cbytes)
$Certificate.PublicKey.Key
When I run run this, I can can see that key field is populated and I can use $Certificate.publickey.key.encrypt to encrypt text. I created a self signed elliptic curve X509 certificate and used the same method to view the public key, but powershell returns the key field as empty and I cannot use $Certificate.publickey.key.encrypt to encrypt text. I see a public key when I view the cert through the gui, so I don't understand why Powershell does not see it. What I am missing?