Попытка запустить Azure Служба Fabri c в моем локальном приложении, все службы работают, кроме той, которая выбрасывает сертификат, не может быть пустым исключением. Ниже приведен фрагмент кода для получения сертификата.
Установлен сертификат на моем локальном для локальной машины и текущего пользователя.
![enter image description here](https://i.stack.imgur.com/bGmoi.png)
![enter image description here](https://i.stack.imgur.com/OOooR.png)
/// <summary>
/// Finds the ASP .NET Core HTTPS development certificate in development environment. Update this method to use the appropriate certificate for production environment.
/// </summary>
/// <returns>Returns the ASP .NET Core HTTPS development certificate</returns>
private static X509Certificate2 GetCertificateFromStore()
{
string aspNetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
if (string.Equals(aspNetCoreEnvironment, "Development", StringComparison.OrdinalIgnoreCase))
{
const string aspNetHttpsOid = "1.3.6.1.4.1.311.84.1.1";
const string CNName = "CN=localhost";
using (X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine))
{
store.Open(OpenFlags.ReadOnly);
var certCollection = store.Certificates;
var currentCerts = certCollection.Find(X509FindType.FindByExtension, aspNetHttpsOid, true);
currentCerts = currentCerts.Find(X509FindType.FindByIssuerDistinguishedName, CNName, true);
return currentCerts.Count == 0 ? null : currentCerts[0];
}
}
else
{
throw new NotImplementedException("GetCertificateFromStore should be updated to retrieve the certificate for non Development environment");
}
}