Cannot find X.509 certificate using the following search criteria

I am trying to set up a WCF service hosted in a Windows Azure web role. I have configured the service for message security, so using an unsecured channel, I want to encrypt messages using the X509 certificate. Unfortunately, I cannot get it to work on Azure. Locally I managed to get everything set up correctly.

Here's the web.config of the WCF service:

<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, set the value below to false before deployment -->
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="true"/>
      <serviceCredentials>
        <serviceCertificate findValue="CN=peterpan.cloudapp.net" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
        <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Skillconomy.Cloud.CheckInService.UserValidator, Skillconomy.Cloud.CheckInService" />
      </serviceCredentials>
    </behavior>
  </serviceBehaviors>
</behaviors>

      

I have configured the certificate in the Web role:

enter image description here

And I uploaded the certificate to the Azure portal:

enter image description here

I am getting an exception:

Cannot find X.509 certificate using the following search criteria: StoreName 'My', StoreLocation 'LocalMachine', FindType 'FindBySubjectName', FindValue 'CN = xyz.cloudapp.net'. Description: An unhandled exception occurred during the execution of the current network request. Check out the stack trace for more information on and where it originated in your code.

Exception Details: System.InvalidOperationException: Cannot find X.509 using the following search criteria: StoreName 'My', StoreLocation 'LocalMachine', FindType 'FindBySubjectName', FindValue 'CN = xyz.cloudapp.net'.

What am I missing here?

+3


source to share


2 answers


The problem was solved by changing:

<serviceCertificate findValue="CN=peterpan.cloudapp.net" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />

      

to



<serviceCertificate findValue="CN=peterpan.cloudapp.net" />

      

Doesn't explain what went wrong, but at least it works ...

+1


source


if you are going to use x509FindType = "FindBySubjectName" findValue should be "peterpan.cloudapp.net" - no CN =



+1


source







All Articles