In my Azure App Service which runs a net472 web app, I access certificate from key vault as follows :
var certSecret = await kvClient.GetSecretAsync(kvName, secretName);
I then need to send the certificate to authenticate to an external service
var cert = new X509Certificate2(Convert.FromBase64String(certSecret.Value));
This line throws an error
System.Security.Cryptography.CryptographicException: The system cannot find the file specified.
at System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32 hr)
at System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromBlob(Byte[] rawData, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx)
at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromBlob(Byte[] rawData)
at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(Byte[] rawData)