【问题标题】:Azure failing to find Certificates on Windows Server 2012 Worker RoleAzure 未能在 Windows Server 2012 工作者角色上找到证书
【发布时间】:2013-07-03 19:26:29
【问题描述】:

我目前正在尝试将我们的 Azure 云服务(Web 和 Worker 角色)升级到 .Net 4.5 Framework。 为此,我们必须将 Azure 部署从 Windows Server 2008 更改为 Windows Server 2012。

这需要我们在 ServiceConfiguration 文件中将 OSFamily 从“1”更改为“3”。

当前系统

  • .Net 4.0
  • MVC3
  • EF 4.4
  • Azure 工具 1.6
  • Visual Studio 2010
  • Windows Server 2008

升级系统

  • .Net 4.5
  • MVC4
  • EF 5
  • Azure 工具 1.8
  • Visual Studio 2012
  • Windows Server 2012

当我们查询 Azure 证书以确定我们是处于“生产”还是“暂存”环境时,我遇到了问题。

以下代码行查找证书。 为了清楚起见,缩短了。

// Open the certificate store for the current user.
            X509Store certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
            certStore.Open(OpenFlags.ReadOnly);

            foreach (var cert in certStore.Certificates)
            {
                OutputToFile.OutputDataReceived("Cert - " + cert.FriendlyName + " -- Thumb -- " + cert.Thumbprint);
            }

            // Find the certificate with the specified thumbprint.
            X509Certificate2Collection certCollection = certStore.Certificates.Find(
                                 X509FindType.FindByThumbprint,
                                 thumbPrint,
                                 false);

            // Close the certificate store.
            certStore.Close();

如您所见,我将证书详细信息打印到日志文件中,以查看是否出现故障。 在 OSFamily="1" (Windows Server 2008) 上,这可以完美运行。它会找到证书。

但是,当我设置 OSFamily="3" (Windows Server 2012) 时,日志文件不会从循环中打印证书详细信息。

它在本地也可以正常工作。

这是 Windows Server 2012 的问题还是 Azure 部署的问题? 自从迁移到 Windows Server 2012 后,我是否必须对我的证书执行额外的步骤?

任何方向都将不胜感激。

【问题讨论】:

  • 问题,这只是为了确定您是在生产还是登台?否则我假设您已经通过角色配置添加了证书?
  • 是的,我们使用检查来查看我们是否处于生产或暂存状态,因为我们不想在暂存中的工作人员角色上运行某些作业。证书已添加到配置文件中,并已上传到 azure。我们可以在管理门户的证书下看到它。我们已经上传了 100 次,并且在 OSFamily 为 1 时一切正常,问题仅在 OSFamily 为 3 时存在。
  • 您是否尝试过使用 StoreLocation.LocalMachine 而不是 CurrentUser?我认为当您将证书上传到托管服务时,Azure 会将证书放在此处。
  • 我怀疑这是link的问题的重复问题

标签: .net azure x509certificate .net-4.5 windows-server-2012


【解决方案1】:

我在这里找到了我的问题的答案:Azure Autoscaling works locally but not when deployed

在 OS Family 3 中,WaWorkerHost 运行在“NETWORK SERVICE”账户下,该账户没有私钥访问权限。所以我需要以提升的权限运行该角色。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-30
    • 2013-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多