Managing Secrets in Service Fabric Applications

与世无争的帅哥 提交于 2019-12-11 04:27:00

问题


I am following the instructions at https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-application-secret-management to create a data encipherment certificate and use that certificate to decipher the secrets at runtime. I added below piece of code to my ApplicationManifest.xml file to grant Network Service account read access to a certificate defined by its thumbprint.

<Principals>

<Users>

  <User Name="NetworkSvc" AccountType="NetworkService" />

</Users>

</Principals>

<Policies>

<SecurityAccessPolicies>

  <SecurityAccessPolicy ResourceRef="secretsEnciphermentCert" PrincipalRef="NetworkSvc" GrantRights="Full" ResourceType="Certificate" />

</SecurityAccessPolicies>

</Policies>

<Certificates>

<EndpointCertificate X509FindValue="thumbprintValue" Name="secretsEnciphermentCert" />

</Certificates>

Now, I am not able to deploy the package to local cluster. It always fails with these errors

Register-ServiceFabricApplicationType : Value cannot be null.

Parameter name: source

At C:\Program Files\Microsoft SDKs\Service 

Fabric\Tools\PSModule\ServiceFabricSDK\Publish-NewServiceFabricApplication.ps1:251 char:9

+         Register-ServiceFabricApplicationType -ApplicationPathInImage ...

+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

     + CategoryInfo          : InvalidOperation: (Microsoft.Servi...usterConnection:ClusterConnection) [Register-Servic 

     eFabricApplicationType], FabricException

    + FullyQualifiedErrorId : RegisterApplicationTypeErrorId,Microsoft.ServiceFabric.Powershell.RegisterApplicationTyp 

    e

回答1:


You're using an EndpointCertificate certificate, while the example uses a SecretsCertificate

<ApplicationManifest … >
    <Principals>
        <Users>
            <User Name="Service1" AccountType="NetworkService" />
        </Users>
    </Principals>
  <Policies>
    <SecurityAccessPolicies>
      <SecurityAccessPolicy GrantRights=”Read” PrincipalRef="Service1" ResourceRef="MyCert" ResourceType="Certificate"/>
    </SecurityAccessPolicies>
  </Policies>
  <Certificates>
    <SecretsCertificate Name="MyCert" X509FindType="FindByThumbprint" X509FindValue="[YourCertThumbrint]"/>
  </Certificates>
</ApplicationManifest>

Also, make sure you don't have an invisible character in the thumbprint.

When copying a certificate thumbprint from the certificate store snap-in on Windows, an invisible character is placed at the beginning of the thumbprint string. This invisible character can cause an error when trying to locate a certificate by thumbprint, so be sure to delete this extra character



来源:https://stackoverflow.com/questions/47842212/managing-secrets-in-service-fabric-applications

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!