/
githubmirror
/
aspnetcore
Обзор
Документация
Войти
/
githubmirror
/
aspnetcore
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/DataProtection/Extensions/test/X509StoreIsAvailableAttribute.cs
42 строки
1 KB
William Godbe
Rename Microsoft.Aspnetcore.Testing to Microsoft.AspNetCore.InternalTesting (#51713)
02 ноя 2023, 03:15
Не верифицирован
02 ноя 2023, 03:15
fc8deca
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Security.Cryptography.X509Certificates; using Microsoft.AspNetCore.InternalTesting; namespace Microsoft.AspNetCore.DataProtection; [AttributeUsage(AttributeTargets.Method)] public class X509StoreIsAvailableAttribute : Attribute, ITestCondition { public X509StoreIsAvailableAttribute(StoreName name, StoreLocation location) { Name = name; Location = location; } public bool IsMet { get { try { using (var store = new X509Store(Name, Location)) { store.Open(OpenFlags.ReadWrite); return true; } } catch { return false; } } } public string SkipReason => $"Skipping because the X509Store({Name}/{Location}) is not available on this machine."; public StoreName Name { get; } public StoreLocation Location { get; } }