I was automating installing a certificate with a task scheduler.The certificate contains private key in a pfx file. When i install the pfx file with double click it works fine with my dot net project. But while i install it with powershell command :
$password = ConvertTo-SecureString "apass" -AsPlainText -Force
Import-PfxCertificate –FilePath C:\cert\certMob2019.pfx cert:\localMachine\Root -Password $password
the certificate install successfully in correct store. But my dot net project generate this error:
System.Security.Cryptography.CryptographicException: 'Object contains only the public half of a key pair. A private key must also be provided.'