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

◆ ReceiveBlobAsync< TIOAdapter >()

async ValueTask< ProtocolToken > System.Net.Security.SslStream.ReceiveBlobAsync< TIOAdapter > ( TIOAdapter adapter)
inlineprivate
Type Constraints
TIOAdapter :IReadWriteAdapter 

Definition at line 1215 of file SslStream.cs.

1215 : IReadWriteAdapter
1216 {
1217 if (await FillHandshakeBufferAsync(adapter, 5).ConfigureAwait(continueOnCapturedContext: false) == 0)
1218 {
1219 throw new IOException(System.SR.net_io_eof);
1220 }
1221 if (_framing == Framing.Unified || _framing == Framing.Unknown)
1222 {
1224 }
1225 if (_framing != Framing.SinceSSL3)
1226 {
1227 _lastFrame.Header.Version = SslProtocols.Ssl2;
1228 _lastFrame.Header.Length = GetFrameSize(_handshakeBuffer.ActiveReadOnlySpan) - 5;
1229 }
1230 else
1231 {
1232 TlsFrameHelper.TryGetFrameHeader(_handshakeBuffer.ActiveReadOnlySpan, ref _lastFrame.Header);
1233 }
1234 if (_lastFrame.Header.Length < 0)
1235 {
1236 if (System.Net.NetEventSource.Log.IsEnabled())
1237 {
1238 System.Net.NetEventSource.Error(this, "invalid TLS frame size", "ReceiveBlobAsync");
1239 }
1241 }
1242 int frameSize = _lastFrame.Header.Length + 5;
1243 if (_handshakeBuffer.ActiveLength < frameSize)
1244 {
1245 await FillHandshakeBufferAsync(adapter, frameSize).ConfigureAwait(continueOnCapturedContext: false);
1246 }
1247 switch (_lastFrame.Header.Type)
1248 {
1249 case TlsContentType.Alert:
1250 if (TlsFrameHelper.TryGetFrameInfo(_handshakeBuffer.ActiveReadOnlySpan, ref _lastFrame) && System.Net.NetEventSource.Log.IsEnabled() && _lastFrame.AlertDescription != 0)
1251 {
1252 System.Net.NetEventSource.Error(this, $"Received TLS alert {_lastFrame.AlertDescription}", "ReceiveBlobAsync");
1253 }
1254 break;
1255 case TlsContentType.Handshake:
1256 {
1258 {
1259 break;
1260 }
1261 TlsFrameHelper.ProcessingOptions options = ((!System.Net.NetEventSource.Log.IsEnabled()) ? TlsFrameHelper.ProcessingOptions.ServerName : TlsFrameHelper.ProcessingOptions.All);
1262 if (!TlsFrameHelper.TryGetFrameInfo(_handshakeBuffer.ActiveReadOnlySpan, ref _lastFrame, options) && System.Net.NetEventSource.Log.IsEnabled())
1263 {
1264 System.Net.NetEventSource.Error(this, $"Failed to parse TLS hello.", "ReceiveBlobAsync");
1265 }
1266 if (_lastFrame.HandshakeType == TlsHandshakeType.ClientHello)
1267 {
1268 if (_lastFrame.TargetName != null)
1269 {
1270 _sslAuthenticationOptions.TargetHost = _lastFrame.TargetName;
1271 }
1273 {
1274 SslServerAuthenticationOptions sslServerAuthenticationOptions = await _sslAuthenticationOptions.ServerOptionDelegate(this, new SslClientHelloInfo(_sslAuthenticationOptions.TargetHost, _lastFrame.SupportedVersions), _sslAuthenticationOptions.UserState, adapter.CancellationToken).ConfigureAwait(continueOnCapturedContext: false);
1275 _sslAuthenticationOptions.UpdateOptions(sslServerAuthenticationOptions);
1276 }
1277 }
1278 if (System.Net.NetEventSource.Log.IsEnabled())
1279 {
1280 System.Net.NetEventSource.Log.ReceivedFrame(this, _lastFrame);
1281 }
1282 break;
1283 }
1284 case TlsContentType.AppData:
1285 if (_isRenego && SslProtocol != SslProtocols.Tls13)
1286 {
1288 }
1289 break;
1290 }
1291 return ProcessBlob(frameSize);
1292 }
static readonly System.Net.NetEventSource Log
static void Error(object thisOrContextObject, FormattableString formattableString, [CallerMemberName] string memberName=null)
void UpdateOptions(SslServerAuthenticationOptions sslServerAuthenticationOptions)
TlsFrameHelper.TlsFrameInfo _lastFrame
Definition SslStream.cs:70
int GetFrameSize(ReadOnlySpan< byte > buffer)
ProtocolToken ProcessBlob(int frameSize)
Framing DetectFraming(ReadOnlySpan< byte > bytes)
SslAuthenticationOptions _sslAuthenticationOptions
Definition SslStream.cs:62
virtual SslProtocols SslProtocol
Definition SslStream.cs:135
static string net_frame_read_size
Definition SR.cs:86
static string net_io_eof
Definition SR.cs:40
static string net_ssl_renegotiate_data
Definition SR.cs:122
Definition SR.cs:7
ReadOnlySpan< byte > ActiveReadOnlySpan

References System.Net.Security.SslStream._framing, System.Net.Security.SslStream._handshakeBuffer, System.Net.Security.SslStream._isRenego, System.Net.Security.SslStream._lastFrame, System.Net.Security.SslStream._sslAuthenticationOptions, System.Net.ArrayBuffer.ActiveLength, System.Net.ArrayBuffer.ActiveReadOnlySpan, System.Net.Security.SslStream.DetectFraming(), System.Net.NetEventSource.Error(), System.Net.Security.SslStream.GetFrameSize(), System.Net.NetEventSource.Log, System.SR.net_frame_read_size, System.SR.net_io_eof, System.SR.net_ssl_renegotiate_data, System.options, System.Net.Security.SslStream.ProcessBlob(), System.Net.Security.SslAuthenticationOptions.ServerCertSelectionDelegate, System.Net.Security.SslAuthenticationOptions.ServerOptionDelegate, System.Net.Security.SslStream.SslProtocol, System.Net.Security.SslAuthenticationOptions.TargetHost, System.Net.Security.TlsFrameHelper.TryGetFrameHeader(), System.Net.Security.TlsFrameHelper.TryGetFrameInfo(), System.Net.Security.SslAuthenticationOptions.UpdateOptions(), and System.Net.Security.SslAuthenticationOptions.UserState.