Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ForceAuthenticationAsync< TIOAdapter >()

async Task System.Net.Security.SslStream.ForceAuthenticationAsync< TIOAdapter > ( TIOAdapter adapter,
bool receiveFirst,
byte[] reAuthenticationData,
bool isApm = false )
inlineprivate
Type Constraints
TIOAdapter :IReadWriteAdapter 

Definition at line 1117 of file SslStream.cs.

1117 : IReadWriteAdapter
1118 {
1119 bool handshakeCompleted = false;
1120 if (reAuthenticationData == null && Interlocked.Exchange(ref _nestedAuth, 1) == 1)
1121 {
1122 throw new InvalidOperationException(System.SR.Format(System.SR.net_io_invalidnestedcall, isApm ? "BeginAuthenticate" : "Authenticate", "authenticate"));
1123 }
1124 try
1125 {
1126 if (!receiveFirst)
1127 {
1128 ProtocolToken message = _context.NextMessage(reAuthenticationData);
1129 if (message.Size > 0)
1130 {
1131 await adapter.WriteAsync(message.Payload, 0, message.Size).ConfigureAwait(continueOnCapturedContext: false);
1132 await adapter.FlushAsync().ConfigureAwait(continueOnCapturedContext: false);
1133 if (System.Net.NetEventSource.Log.IsEnabled())
1134 {
1135 System.Net.NetEventSource.Log.SentFrame(this, message.Payload);
1136 }
1137 }
1138 if (message.Failed)
1139 {
1140 throw new AuthenticationException(System.SR.net_auth_SSPI, message.GetException());
1141 }
1142 if (message.Status.ErrorCode == SecurityStatusPalErrorCode.OK)
1143 {
1144 handshakeCompleted = true;
1145 }
1146 }
1147 if (!handshakeCompleted)
1148 {
1149 _handshakeBuffer = new ArrayBuffer(4160);
1150 }
1151 while (!handshakeCompleted)
1152 {
1153 ProtocolToken message = await ReceiveBlobAsync(adapter).ConfigureAwait(continueOnCapturedContext: false);
1154 byte[] payload = null;
1155 int num = 0;
1156 if (message.Size > 0)
1157 {
1158 payload = message.Payload;
1159 num = message.Size;
1160 }
1161 else if (message.Failed && (_lastFrame.Header.Type == TlsContentType.Handshake || _lastFrame.Header.Type == TlsContentType.ChangeCipherSpec))
1162 {
1163 payload = TlsFrameHelper.CreateAlertFrame(_lastFrame.Header.Version, TlsAlertDescription.ProtocolVersion);
1164 num = payload.Length;
1165 }
1166 if (payload != null && num > 0)
1167 {
1168 await adapter.WriteAsync(payload, 0, num).ConfigureAwait(continueOnCapturedContext: false);
1169 await adapter.FlushAsync().ConfigureAwait(continueOnCapturedContext: false);
1170 if (System.Net.NetEventSource.Log.IsEnabled())
1171 {
1172 System.Net.NetEventSource.Log.SentFrame(this, payload);
1173 }
1174 }
1175 if (message.Failed)
1176 {
1177 if (System.Net.NetEventSource.Log.IsEnabled())
1178 {
1179 System.Net.NetEventSource.Error(this, message.Status, "ForceAuthenticationAsync");
1180 }
1181 if (_lastFrame.Header.Type == TlsContentType.Alert && _lastFrame.AlertDescription != 0 && message.Status.ErrorCode == SecurityStatusPalErrorCode.IllegalMessage)
1182 {
1183 throw new AuthenticationException(System.SR.Format(System.SR.net_auth_tls_alert, _lastFrame.AlertDescription.ToString()), message.GetException());
1184 }
1185 throw new AuthenticationException(System.SR.net_auth_SSPI, message.GetException());
1186 }
1187 if (message.Status.ErrorCode == SecurityStatusPalErrorCode.OK)
1188 {
1189 handshakeCompleted = true;
1190 }
1191 }
1193 {
1197 }
1199 }
1200 finally
1201 {
1203 if (reAuthenticationData == null)
1204 {
1205 _nestedAuth = 0;
1206 _isRenego = false;
1207 }
1208 }
1209 if (System.Net.NetEventSource.Log.IsEnabled())
1210 {
1212 }
1213 }
static readonly System.Net.NetEventSource Log
static void Error(object thisOrContextObject, FormattableString formattableString, [CallerMemberName] string memberName=null)
ProtocolToken NextMessage(ReadOnlySpan< byte > incomingBuffer)
virtual ExchangeAlgorithmType KeyExchangeAlgorithm
Definition SslStream.cs:224
virtual HashAlgorithmType HashAlgorithm
Definition SslStream.cs:206
TlsFrameHelper.TlsFrameInfo _lastFrame
Definition SslStream.cs:70
virtual CipherAlgorithmType CipherAlgorithm
Definition SslStream.cs:188
SslAuthenticationOptions _sslAuthenticationOptions
Definition SslStream.cs:62
bool CompleteHandshake(ref ProtocolToken alertToken, out SslPolicyErrors sslPolicyErrors, out X509ChainStatusFlags chainStatus)
virtual SslProtocols SslProtocol
Definition SslStream.cs:135
static string net_io_invalidnestedcall
Definition SR.cs:24
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string net_auth_tls_alert
Definition SR.cs:76
static string net_auth_SSPI
Definition SR.cs:72
Definition SR.cs:7
static int Exchange(ref int location1, int value)
Span< byte > ActiveSpan
void CopyTo(Span< T > destination)
Definition Span.cs:224

References System.Net.Security.SslStream._context, System.Net.Security.SslStream._handshakeBuffer, System.Net.Security.SslStream._internalBuffer, System.Net.Security.SslStream._internalBufferCount, System.Net.Security.SslStream._isRenego, System.Net.Security.SslStream._lastFrame, System.Net.Security.SslStream._nestedAuth, System.Net.Security.SslStream._sslAuthenticationOptions, System.Net.ArrayBuffer.ActiveLength, System.Net.ArrayBuffer.ActiveSpan, System.Net.Security.SslStream.CipherAlgorithm, System.Net.Security.SslStream.CipherStrength, System.Net.Security.SslStream.CompleteHandshake(), System.Span< T >.CopyTo(), System.Net.Security.TlsFrameHelper.CreateAlertFrame(), System.Net.ArrayBuffer.Dispose(), System.Net.NetEventSource.Error(), System.Net.SecurityStatusPal.ErrorCode, System.Threading.Interlocked.Exchange(), System.Net.Security.ProtocolToken.Failed, System.SR.Format(), System.Net.Security.ProtocolToken.GetException(), System.Net.Security.SslStream.HashStrength, System.Net.Security.SslStream.KeyExchangeAlgorithm, System.Net.Security.SslStream.KeyExchangeStrength, System.Net.NetEventSource.Log, System.SR.net_auth_SSPI, System.SR.net_auth_tls_alert, System.SR.net_io_invalidnestedcall, System.Net.Security.SecureChannel.NextMessage(), System.Net.Security.ProtocolToken.Payload, System.Net.Security.SslStream.ResetReadBuffer(), System.Net.Security.ProtocolToken.Size, System.Net.Security.SslStream.SslProtocol, and System.Net.Security.ProtocolToken.Status.