Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You might be able to achieve this in Silverlight by <strong>allowing cross-domain communication</strong> between the web server the hosts the Silverlight application and the remote WCF service.</p> <p>In that case you need to place a <a href="http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html" rel="noreferrer"><strong>clientaccesspolicy.xml</strong></a> file at the root of the domain where the WCF service is hosted:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;access-policy&gt; &lt;cross-domain-access&gt; &lt;policy&gt; &lt;allow-from http-request-headers="SOAPAction"&gt; &lt;domain uri="http://*"/&gt; &lt;/allow-from&gt; &lt;grant-to&gt; &lt;resource path="/" include-subpaths="true"/&gt; &lt;/grant-to&gt; &lt;/policy&gt; &lt;/cross-domain-access&gt; &lt;/access-policy&gt; </code></pre> <p>Here's what <a href="http://msdn.microsoft.com/en-us/library/cc197955(v=vs.95).aspxhttp://msdn.microsoft.com/en-us/library/cc197955(v=vs.95).aspx" rel="noreferrer">MSDN states about this approach</a>:</p> <blockquote> <p>To allow access to an HTTPS service from any Silverlight control hosted over HTTP application, you need to put the <em>&lt;domain uri=”http://</em>” /&gt;* element inside your <em>&lt;allow-from&gt;</em> element.</p> </blockquote> <p>I haven't tried this myself but it could be worth a shot. Also be sure to check out the following resources for more details:</p> <ul> <li><a href="http://msdn.microsoft.com/en-us/library/cc197955(v=vs.95).aspxhttp://msdn.microsoft.com/en-us/library/cc197955(v=vs.95).aspx" rel="noreferrer">Making a Service Available Across Domain Boundaries</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/cc197941(v=vs.95).aspx" rel="noreferrer">Configuring Web Service Usage in Silverlight Clients</a></li> </ul> <hr> <h2>Disabling X.509 certificate validation in .NET</h2> <p>For .NET applications this sample WCF configuration will disable validation of both whether the certificate is trusted and whether it is still valid on the client:</p> <pre><code>&lt;system.serviceModel&gt; &lt;behaviors&gt; &lt;endpointBehaviors&gt; &lt;behavior name="DisableServiceCertificateValidation"&gt; &lt;clientCredentials&gt; &lt;serviceCertificate&gt; &lt;authentication certificateValidationMode="None" revocationMode="NoCheck" /&gt; &lt;/serviceCertificate&gt; &lt;/clientCredentials&gt; &lt;/behavior&gt; &lt;/endpointBehaviors&gt; &lt;/behaviors&gt; &lt;client&gt; &lt;endpoint address="http://localhost/MyService" behaviorConfiguration="DisableServiceCertificateValidation" binding="wsHttpBinding" contract="MyNamespace.IMyService" name="MyServiceWsHttp" /&gt; &lt;/client&gt; &lt;/system.serviceModel&gt; </code></pre> <p><strong>An alternative solution</strong> is to provide custom logic to validate the X.509 certificate provided by the service. In that case you will have to modifiy the configuration file according to the following:</p> <pre><code>&lt;system.serviceModel&gt; &lt;behaviors&gt; &lt;endpointBehaviors&gt; &lt;behavior name="DisableServiceCertificateValidation"&gt; &lt;clientCredentials&gt; &lt;serviceCertificate&gt; &lt;authentication certificateValidationMode="Custom" customCertificateValidatorType="MyCertificateValidator, Client" revocationMode="NoCheck" /&gt; &lt;/serviceCertificate&gt; &lt;/clientCredentials&gt; &lt;/behavior&gt; &lt;/endpointBehaviors&gt; &lt;/behaviors&gt; &lt;client&gt; &lt;endpoint address="http://localhost/MyService" behaviorConfiguration="DisableServiceCertificateValidation" binding="wsHttpBinding" contract="MyNamespace.IMyService" name="MyServiceWsHttp" /&gt; &lt;/client&gt; &lt;/system.serviceModel&gt; </code></pre> <p>Then create a class that derives from <a href="http://msdn.microsoft.com/en-us/library/system.identitymodel.selectors.x509certificatevalidator.aspx" rel="noreferrer">X509CertificateValidator</a> to implement your custom validation logic.</p> <pre><code>public class MyCertificateValidator : X509CertificateValidator { public override void Validate(X509Certificate2 certificate) { // Add custom validation logic // Throw an exception to fail validation } } </code></pre> <p>As always, you can find <a href="http://msdn.microsoft.com/en-us/library/aa354512.aspx" rel="noreferrer">a more detailed example</a> up on MSDN.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload