NotSupportedException when calling WCF service (Crypto algorithm not supported in this context)

1

I am trying to use a WCF with federation. Therefore my client obtains a token from the STS, opens the channel with the issued token and finally calls the service.

Then, I am getting the following exception:

System.NotSupportedException
HResult=0x80131515
Message=Crypto algorithm  not supported in this context.
Source=mscorlib
StackTrace:
    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
    at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
    at FederatedClientForWCF.MySomeService.ISomeService.Revert(String text)
    at FederatedClientForWCF.Program.Main(String[] args) in D:\Spikes\FederatedClientForWCF\FederatedClientForWCF\Program.cs:line 81

Note, that the name of the algorithm is missing.

Here is my client code (without the details of obtaining the token):

// get the token
var token = RequestTrustToken();

// setup the binding
var binding = new CustomBinding(
    SymmetricSecurityBindingElement.CreateIssuedTokenBindingElement(
        new IssuedSecurityTokenParameters("http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1")),
    new TextMessageEncodingBindingElement(),
    new HttpTransportBindingElement());

// explicitely use relative fed-endpoint
var endpointAddress = new EndpointAddress("http://localhost:53279/service/someservice/fed");

// build the factory
var factory = new ChannelFactory<ISomeService>(binding, endpointAddress);
factory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
factory.Credentials.ServiceCertificate.Authentication.RevocationMode = X509RevocationMode.NoCheck;
factory.Credentials.SupportInteractive = false;

// create channel
var channel = factory.CreateChannelWithIssuedToken(token);

// try it
var reverted = channel.Revert(helloWorld);

On the service side the service configuration looks like this, I've left the identity configuration out, but if needed I can post it:

  <!-- Der Service der gehostet wird. -->
  <service name="SomeService.SomeService" behaviorConfiguration="SomeServiceBehavior">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:53279/service/someservice"/>
      </baseAddresses>
    </host>
    <endpoint address="" binding="wsHttpBinding" contract="SomeService.Contract.ISomeService"/>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    <endpoint address="fed" binding="customBinding" bindingConfiguration="federatedBinding" contract="SomeService.Contract.ISomeService" />
  </service>
</services>
<bindings>
  <customBinding>
    <binding name="federatedBinding">
      <security authenticationMode="IssuedToken">
        <issuedTokenParameters tokenType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1" keyType="SymmetricKey" />
      </security>
      <textMessageEncoding />
      <httpTransport />
    </binding>
  </customBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="SomeServiceBehavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
      <serviceCredentials useIdentityConfiguration="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>
</system.serviceModel>

What does the exception mean? Am I missing a crypto algortihm anywhere?

.net
wcf
wif
asked on Stack Overflow Feb 14, 2019 by MiGro

1 Answer

0

Already fixed that some time ago by using a configuration approach rather than setting up binding and all manual by code. The pinpoint is to use SecurityBinding instead of SymetricSecurityBinding:

var binding = new CustomBinding(
    SecurityBindingElement.CreateIssuedTokenBindingElement(
        new IssuedSecurityTokenParameters("http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1")),
    new TextMessageEncodingBindingElement(),
    new HttpTransportBindingElement());
answered on Stack Overflow Jun 26, 2019 by MiGro

User contributions licensed under CC BY-SA 3.0