title: Cannot find the X.509 certificate using the following search criteria
body: <p>I'm trying to set up a WCF service hosted in a Windows Azure Web Role. I've configured the service for message security, so while using an unsecured channel, I want to encrypt the messages using a X509 certificate. Unfortunately, I can't get it to work on Azure. Locally I managed to set everything up correctly.</p>
  
  <p>Here's the web.config of the WCF service:</p>
  
  <pre><code>&lt;behaviors&gt;
    &lt;serviceBehaviors&gt;
      &lt;behavior&gt;
        &lt;!-- To avoid disclosing metadata information, set the value below to false before deployment --&gt;
        &lt;serviceMetadata httpGetEnabled="true" httpsGetEnabled="false"/&gt;
        &lt;!-- 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 --&gt;
        &lt;serviceDebug includeExceptionDetailInFaults="true"/&gt;
        &lt;serviceCredentials&gt;
          &lt;serviceCertificate findValue="CN=peterpan.cloudapp.net" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" /&gt;
          &lt;userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Skillconomy.Cloud.CheckInService.UserValidator, Skillconomy.Cloud.CheckInService" /&gt;
        &lt;/serviceCredentials&gt;
      &lt;/behavior&gt;
    &lt;/serviceBehaviors&gt;
  &lt;/behaviors&gt;
  </code></pre>
  
  <p>I've configured the certificate in the Web Role:</p>
  
  <p><img src="https://i.stack.imgur.com/ar1FF.png" alt="enter image description here"></p>
  
  <p>And I've uploaded the certificate in the Azure portal:</p>
  
  <p><img src="https://i.stack.imgur.com/WVZn1.png" alt="enter image description here"></p>
  
  <p>I get the exception:</p>
  
  <blockquote>
    <p>Cannot find the 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 web
    request. Please review the stack trace for more information about the
    error and where it originated in the code.</p>
    
    <p>Exception Details: System.InvalidOperationException: Cannot find the
    X.509 certificate using the following search criteria: StoreName 'My',
    StoreLocation 'LocalMachine', FindType 'FindBySubjectName', FindValue
    'CN=xyz.cloudapp.net'.</p>
  </blockquote>
  
  <p>What am I missing here?</p>