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


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:

Message=Crypto algorithm  not supported in this context.
    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(
        new IssuedSecurityTokenParameters("")),
    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">
        <add baseAddress="http://localhost:53279/service/someservice"/>
    <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" />
    <binding name="federatedBinding">
      <security authenticationMode="IssuedToken">
        <issuedTokenParameters tokenType="" keyType="SymmetricKey" />
      <textMessageEncoding />
      <httpTransport />
    <behavior name="SomeServiceBehavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
      <serviceCredentials useIdentityConfiguration="true" />

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

asked on Stack Overflow Feb 14, 2019 by MiGro

1 Answer


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(
        new IssuedSecurityTokenParameters("")),
    new TextMessageEncodingBindingElement(),
    new HttpTransportBindingElement());
answered on Stack Overflow Jun 26, 2019 by MiGro

User contributions licensed under CC BY-SA 3.0