internal void ReplyOnReAuthentication(byte[] buffer)
{
lock (this)
{
// Note we are already inside the read, so checking for already going concurrent handshake.
_lockReadState = LockHandshake;
if (_pendingReHandshake)
{
// A concurrent handshake is pending, resume.
FinishRead(buffer);
return;
}
}
// Start rehandshake from here.
// Forcing async mode. The caller will queue another Read as soon as we return using its preferred
// calling convention, which will be woken up when the handshake completes. The callback is just
// to capture any SocketErrors that happen during the handshake so they can be surfaced from the Read.
AsyncProtocolRequest asyncRequest = new AsyncProtocolRequest(new LazyAsyncResult(this, null, new AsyncCallback(RehandshakeCompleteCallback)));
// Buffer contains a result from DecryptMessage that will be passed to ISC/ASC
asyncRequest.Buffer = buffer;
ForceAuthentication(false, buffer, asyncRequest);
}