Azure Service Fabric 上的无状态 Web Api 通过 https

Stateless Web Api on Azure Service Fabric over https

所以我有一个 Web Api 托管在 Azure Service Fabric 上,我想通过 https 公开它。

第一个问题:微软提供的*.cloudapp.azure.com的默认证书是否与App Service类似?

如果没有,我如何才能拥有一个不属于我的域的有效证书(由知名 CA 颁发)?

万一有可能,我想我需要将此证书上传到 Azure Vault 并在服务清单中引用它的指纹,对吗?

我是否应该使用相同的证书来保护集群和公开 SSL 端点?

谢谢!

*.cloudapp.azure.com 没有通配符证书,就像 *.azurewebsites.net 一样。对于 SSL,您必须注册自己的域并将其 CNAME 到您的集群域(例如 mycluster.westus.cloudapp.azure.com),或者为您的负载均衡器 VIP 获取静态 public IP 并指向你的 A 记录到那个 (more on public IPs in Azure here)。然后从您最喜欢的 CA 为该域购买证书。

获得证书后,是的,您会将其存储在 Key Vault 中(确保在创建 Key Vault 时设置 -EnabledForDeployment!)并将其放入您的群集 ARM 模板 (to get it installed on your nodes)。

要使用 HTTPS,首先在 ApplicationManifest.xml 中设置证书引用:

<Certificates>
   <EndpointCertificate X509FindValue="<Your Certificate Thumbprint>" Name="Cert1" />
</Certificates>

然后在Application Manifest的ServiceManifestImport部分设置EndpointBindindPolicy:

<ServiceManifestImport>
...
   <Policies>
      <EndpointBindingPolicy EndpointRef="ServiceEndpoint" CertificateRef="Cert1" />
   </Policies>
</ServiceManifestImport>

最后,在 ServiceManifest.xml:

中的端点配置中引用证书
<Endpoints>
  <Endpoint Name="ServiceEndpoint" Type="Input" Protocol="https" Port="443" CertificateRef="Cert1"/>
</Endpoints>

可以使用相同的证书来保护您的集群并向用户提供 SSL,但我建议您使用不同的证书,这样您就不会将服务器证书分发给用于集群身份验证的客户端。

编辑:也可以使用支持 SSL 卸载的 Azure Application Gateway。然后它将处理 HTTPS 方面并将 HTTP 返回给集群