Как прочитать сертификат, если веб-приложение размещено в службе приложений AzureC#

Место общения программистов C#
Ответить Пред. темаСлед. тема
Гость
 Как прочитать сертификат, если веб-приложение размещено в службе приложений Azure

Сообщение Гость »


У меня есть приложение asp.net core web api (app1), которое вызывает другой asp.net core web api (app2), и я рассматриваю app1 как приложение deamon, и я хотел бы отслеживать учетные данные клиента с помощью сертификата, а не приложения. секреты.
https://github.com/Azure-Samples/active ... pplication -using-client-credentials-with-certificates
Все работает нормально, пока оба моих and running in local machine where I am reading the certificate like below,

Код: Выделить всё

private static X509Certificate2 ReadCertificate(string certificateName)
{
if (string.IsNullOrWhiteSpace(certificateName))
{
throw new ArgumentException("certificateName should not be empty. Please set the CertificateName setting in the appsettings.json", "certificateName");
}
X509Certificate2 cert = null;

using (X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser))
{
store.Open(OpenFlags.ReadOnly);
X509Certificate2Collection certCollection = store.Certificates;

// Find unexpired certificates.
X509Certificate2Collection currentCerts = certCollection.Find(X509FindType.FindByTimeValid, DateTime.Now, false);

// From the collection of unexpired certificates, find the ones with the correct name.
X509Certificate2Collection signingCert = currentCerts.Find(X509FindType.FindBySubjectDistinguishedName, certificateName, false);

// Return the first certificate in the collection, has the right name and is current.
cert = signingCert.OfType().OrderByDescending(c => c.NotBefore).FirstOrDefault();
}
return cert;
}
The certificate is in local machine and I am reading it from here,

Код: Выделить всё

 using (X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser))
Now I want to host both app1 & 2 with azure app service, now question is how to read certificate?
Thanks!


Источник: https://stackoverflow.com/questions/626 ... pp-service
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «C#»