Description
Describe the bug
I experimented with using WSTrustChannelSecurityTokenProvider
to issue a token via WS-Trust, much like described in #4542. Then I ran into a problem when the STS responded with a SOAP Fault, which contained information that the code needed to act on.
The problem is that GetTokenCore
uses try..finally
to always call channel.Close()
(source code), but if the channel has entered a faulted state it results in CommunicationObjectFaultedException
, which in turn hides the SOAP Fault exception that had been thrown.
I believe the code in the finally block should examine the state of the channel and instead call Abort()
in a faulted state.
It was just an experiment and I ended up using WSTrustChannelFactory
instead for this, but I still want to report it, as it could hide valuable exception information in a normal WsFederationHttpBinding
use case.
To Reproduce
Steps to reproduce the behavior:
- Attempt to request a security token with similar code as found in UserName Endpoint STS #4542.
- Make sure the STS responds with a SOAP Fault.
Expected behavior
The SOAP Fault exception should not be hidden by a CommunicationObjectFaultedException
.
Additional context
This was tested with .NET 8 and System.ServiceModel.Federation
version 8.0.0.