<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-15">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>I'm trying to migrate an existing application to Mono (v2.10.2).</p>
    <p>Therefore I created a test WCF service with BasicHttpBinding and
      message security. The client works perfectly with .NET, but when
      running with Mono it fails.</p>
    <p>The client factory is instantiated as follows:</p>
    <pre class="default prettyprint"><code><span class="com"></span><span class="com"></span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> certificate </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> X509Certificate2</span><span class="pun">(</span><span class="str">"certificate.pfx"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"password"</span><span class="pun">);</span><span class="pln">

</span><span class="kwd">var</span><span class="pln"> binding </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">BasicHttpBinding</span><span class="pun">();</span><span class="pln">
binding</span><span class="pun">.</span><span class="typ">Security</span><span class="pun">.</span><span class="typ">Mode</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="typ">BasicHttpSecurityMode</span><span class="pun">.</span><span class="typ">Message</span><span class="pun">;</span><span class="pln">
binding</span><span class="pun">.</span><span class="typ">Security</span><span class="pun">.</span><span class="typ">Message</span><span class="pun">.</span><span class="typ">ClientCredentialType</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="typ">BasicHttpMessageCredentialType</span><span class="pun">.</span><span class="typ">Certificate</span><span class="pun">;</span><span class="pln">

</span><span class="kwd">var</span><span class="pln"> epa </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">EndpointAddress</span><span class="pun">(</span><span class="pln">
    </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">Uri</span><span class="pun">(</span><span class="str"><a class="moz-txt-link-rfc2396E" href="http://localhost:53076/Service1.svc">"http://localhost:53076/Service1.svc"</a></span><span class="pun">),</span><span class="pln">
    </span><span class="kwd">new</span><span class="pln"> X509CertificateEndpointIdentity</span><span class="pun">(</span><span class="pln">certificate</span><span class="pun">));</span><span class="pln">

</span><span class="kwd">var</span><span class="pln"> factory </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">ChannelFactory</span><span class="pun">&lt;</span><span class="typ">IService1</span><span class="pun">&gt;(</span><span class="pln">binding</span><span class="pun">,</span><span class="pln"> epa</span><span class="pun">);</span><span class="pln">
factory</span><span class="pun">.</span><span class="typ">Credentials</span><span class="pun">.</span><span class="typ">ServiceCertificate</span><span class="pun">.</span><span class="typ">DefaultCertificate</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> certificate</span><span class="pun">;</span><span class="pln">
factory</span><span class="pun">.</span><span class="typ">Credentials</span><span class="pun">.</span><span class="typ">ServiceCertificate</span><span class="pun">.</span><span class="typ">Authentication</span><span class="pun">.</span><span class="typ">CertificateValidationMode</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> X509CertificateValidationMode</span><span class="pun">.</span><span class="kwd">None</span><span class="pun">;</span><span class="pln">
factory</span><span class="pun">.</span><span class="typ">Credentials</span><span class="pun">.</span><span class="typ">ServiceCertificate</span><span class="pun">.</span><span class="typ">Authentication</span><span class="pun">.</span><span class="typ">RevocationMode</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> X509RevocationMode</span><span class="pun">.</span><span class="typ">NoCheck</span><span class="pun">;</span><span class="pln">
factory</span><span class="pun">.</span><span class="typ">Credentials</span><span class="pun">.</span><span class="typ">ClientCertificate</span><span class="pun">.</span><span class="typ">Certificate</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> certificate</span><span class="pun">;</span><span class="pln">

</span><span class="kwd">var</span><span class="pln"> client </span><span class="pun">=</span><span class="pln"> factory</span><span class="pun">.</span><span class="typ">CreateChannel</span><span class="pun">();</span><span class="pln">
</span></code></pre>
    <p>In Mono the application fails within CreateChannel throwing the
      exception:</p>
    <blockquote>
      <p>System.InvalidOperationException: The binding does not support
        any of the channel types that the contract 'IService1' allows. </p>
    </blockquote>
    <p>I debugged into the Mono source code and found out that the
      problem is that
      AsymmetricSecurityBindingElement.InitiatorTokenParameter == null.</p>
    <p>I'm new to Mono, maybe you could point me to a
      documentation/tutorial which covers this topic.</p>
  </body>
</html>