Beispiel #1
0
        private static X509Certificate2 GetCertificate(IServiceCollection services, VisaAliasApiOptions visaAliasApiOptions)
        {
            using X509Store store = new(StoreLocation.LocalMachine);
            store.Open(OpenFlags.OpenExistingOnly);
            X509Certificate2Collection certs       = store.Certificates.Find(X509FindType.FindByThumbprint, visaAliasApiOptions.AuthorizationCertificateThumbprint, visaAliasApiOptions.AllowInvalidCertificate);
            X509Certificate2           certificate = certs.OfType <X509Certificate2>().FirstOrDefault();

            if (certificate is null)
            {
                ServiceProvider       serviceProvider       = services.BuildServiceProvider();
                IProblemDetailsHelper _problemDetailsHelper = serviceProvider.GetService <IProblemDetailsHelper>();
                throw new ApiProblemDetailsException(_problemDetailsHelper.GetWrongCertificateProblemDetails());
            }
            return(certificate);
        }
Beispiel #2
0
 public HttpResponseStatusChecker(IProblemDetailsHelper problemDetailsHelper, ICryptographyHelper cryptographyHelper, IOptions <VisaAliasApiOptions> VisaAliasOptions)
 {
     _problemDetailsHelper = problemDetailsHelper;
     _cryptographyHelper   = cryptographyHelper;
     _VisaAliasApiOptions  = VisaAliasOptions.Value;
 }