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.
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've configured the certificate in the Web Role:
And I've uploaded the certificate in the Azure portal:
I get the exception:
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.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'.
What am I missing here?
Best Solution
The problem was solved by changing:
to
Doesn't explain what was wrong exactly, but at least it works...