title: Is there a way to port this WS-Trust code to .NET Core?
body: <p>I have some legacy code (.NET framework) that I want to port to .NET Core 2.1. The intent is to retrieve a token from a WS-Trust compatible STS in order to make calls to WCF services.</p>
  
  <p>The code will effectively run in a new web services layer that needs to fit in the middle of existing systems. These systems may not be able to be modified extensively hence why I am attempting to carry over as much of what already exists as possible.</p>
  
  <p>This will run in an AWS Lambda function hence the .NET Core constraint. </p>
  
  <p>I have looked online but can't find anything that clearly explains how it could be done.</p>
  
  <p>Here's the code to be ported:</p>
  
  <pre class="lang-cs prettyprint-override"><code>var factory = new WSTrustChannelFactory("stsEndpoint") { TrustVersion = TrustVersion.WSTrust13 };
  var channel = factory.CreateChannel();
  var rst = new RequestSecurityToken
  {
      RequestType = WSTrust13Constants.RequestTypes.Issue,
      AppliesTo = new EndpointAddress("endpoint"),
      Context = "context",
  };
  
  rst.Claims.Dialect = "http://docs.oasis-open.org/wsfed/authorization/200706/authclaims";
  rst.Claims.Add(new RequestClaim("http://schemas.microsoft.com/ws/2008/06/identity/claims/role", true, "principal"));
  rst.Claims.Add(new RequestClaim("request", true, id));
  var token = channel.Issue(rst, out RequestSecurityTokenResponse rstr);
  </code></pre>