private static byte[] UnwrapMessage(SafeGssContextHandle context, byte[] message)
{
Interop.NetSecurityNative.GssBuffer unwrapped = default(Interop.NetSecurityNative.GssBuffer);
Interop.NetSecurityNative.Status status;
try
{
Interop.NetSecurityNative.Status minorStatus;
status = Interop.NetSecurityNative.UnwrapBuffer(out minorStatus,
context, message, 0, message.Length, ref unwrapped);
if (status != Interop.NetSecurityNative.Status.GSS_S_COMPLETE)
{
throw new Interop.NetSecurityNative.GssApiException(status, minorStatus);
}
return unwrapped.ToByteArray();
}
finally
{
unwrapped.Dispose();
}
}