如何将公钥证书部署到我的工作者角色的Trusted People
商店?
我正在使用PeerTrust
用于WCF(Azure中的自托管TCP服务):
var creds = new ServiceCredentials();
creds.ClientCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.PeerTrust;
我知道如何在我的.csdef
和代码中引用证书。但是,我不知道如何获取.cer
文件(没有私钥)并实际将其放入Azure中,因此可以将其用于PeerTrust。在线门户中的证书管理器只允许您上传.pfx
个文件(即带有私钥的证书)。
答案 0 :(得分:3)
我只是在考虑您是否可以在使用System.Security.Cryptography.X509Certificates.X509Store
和System.Security.Cryptography.X509Certificates.X509Certificates2
启动角色时从代码中安装CER。您可以使用"复制到输出目录=始终复制"。
答案 1 :(得分:2)
也许情况并非如此,但目前可以在没有任何定制工作的情况下完成此操作。只需编辑服务的.csdef
(云服务定义)文件以包含以下内容 - 或者,如果使用Visual Studio,则使用辅助角色的属性面板:
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="MyService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2013-10.2.2">
<WorkerRole name="MyService.Backend" ... >
<Certificates>
<Certificate name="backend.example.com.selfsigned" storeLocation="LocalMachine" storeName="My" />
<Certificate name="frontend.example.com.selfsigned" storeLocation="LocalMachine" storeName="TrustedPeople" />
</Certificates>
<Endpoints>
<InternalEndpoint name="Internal" protocol="tcp" port="..." />
</Endpoints>
...
</WorkerRole>
<WebRole name="MyService.Frontend" ... >
<Sites>
<Site name="Web">
<Bindings>
<Binding name="WebsitePublicEndpoint" endpointName="Insecure" />
<Binding name="WebsitePublicEndpoint" endpointName="Secure" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="Insecure" protocol="http" port="80" />
<InputEndpoint name="Secure" protocol="https" port="443" certificate="example.com" />
</Endpoints>
<Certificates>
<Certificate name="backend.example.com" storeLocation="LocalMachine" storeName="TrustedPeople" />
<Certificate name="frontend.example.com" storeLocation="LocalMachine" storeName="My" />
<Certificate name="example.com" storeLocation="LocalMachine" storeName="My" />
</Certificates>
...
</WebRole>
</ServiceDefinition>
另请参阅this forum thread和worker role service definition file schema documentation。
此外,Azure门户现在支持上载.cer
(仅限公钥)证书文件。您可能必须更改“打开文件”对话框的选择过滤器 - 默认情况下,它设置为仅查找.pfx
个文件。