public Task <PersonalCertificate> GetCertificateFromMsix(string msixFile, CancellationToken cancellationToken = default, IProgress <ProgressData> progress = null)
{
if (string.IsNullOrEmpty(msixFile))
{
throw new ArgumentNullException(nameof(msixFile));
}
return(Task.Run(
() =>
{
try
{
var x509 = X509Certificate.CreateFromSignedFile(msixFile);
return CreateFromX509(x509, CertificateStoreType.File);
}
catch (Exception e)
{
// This will be probably WindowsCryptographicException but we do not want to expose too much...
Logger.Debug("Selected file {0} is not signed and no certificate could be exported from it (exception of type {1}).", msixFile, e.GetType().Name);
return null;
}
},
cancellationToken));
}