除了将证书添加到“受信任的嘟嘟证书颁发机构”之外,还有什么其他方法可以信任ASP.NET Core中的证书

问题描述

我正在尝试在生产模式下使用HTTPS在Azure Windows VM上配置SignalR工作器服务。我正在尝试使用this guide加载在本地计算机上安装的名为services-dev的证书,但是我想跳过将证书添加到受信任的根证书颁发机构/证书的步骤。 em>。

如果证书仅位于个人/证书中,是否可以加载证书?

我的KestrelServerOptionsExtensions类的当前版本如下:

      var configuration = options.ApplicationServices.GetRequiredService<IConfiguration>();
      var environment = options.ApplicationServices.GetRequiredService<IHostEnvironment>();

      var signalRConfiguration = configuration.GetSection("SignalRSettings");
      options.ListenAnyIP(signalRConfiguration.GetValue<int>("Port"));
      options.ListenAnyIP(signalRConfiguration.GetValue<int>("SecurePort"),listenOptions => {
        var certificate = LoadCertificate(signalRConfiguration,environment);
        listenOptions.UseHttps(certificate);
      });

将LoadCertificate缩小为:

        using var store = new X509Store(storeName,Enum.Parse<StoreLocation>(storeLocation));
        store.Open(OpenFlags.ReadOnly);
        var certificate = store.Certificates.Find(
            X509FindType.FindBySubjectName,certificateName,validOnly: !environment.IsDevelopment());

        if (certificate.Count == 0) {
          Logger.Debug("Did not find any certificate");
          throw new InvalidOperationException($"Certificate not found for {certificateName}.");
        }

        return certificate[0];

相关的应用设置配置:

  "SignalRSettings": {
    "Port": 8082,"SecurePort": 8081,"CertificateName": "services-dev","StoreLocation": "LocalMachine","StoreName": "My"
  }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...