Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SslAuthenticationOptions.cs
Go to the documentation of this file.
1
using
System.Collections.Generic
;
2
using
System.Runtime.CompilerServices
;
3
using
System.Security.Authentication
;
4
using
System.Security.Cryptography.X509Certificates
;
5
6
namespace
System.Net.Security
;
7
8
internal
sealed
class
SslAuthenticationOptions
9
{
10
[
CompilerGenerated
]
11
private
CipherSuitesPolicy
_003CCipherSuitesPolicy_003Ek__BackingField
;
12
13
internal
bool
AllowRenegotiation
{
get
;
set
; }
14
15
internal
string
TargetHost
{
get
;
set
; }
16
17
internal
X509CertificateCollection
ClientCertificates
{
get
;
set
; }
18
19
internal
List<SslApplicationProtocol>
ApplicationProtocols
{
get
;
set
; }
20
21
internal
bool
IsServer
{
get
;
set
; }
22
23
internal
SslStreamCertificateContext
CertificateContext
{
get
;
set
; }
24
25
internal
SslProtocols
EnabledSslProtocols
{
get
;
set
; }
26
27
internal
X509RevocationMode
CertificateRevocationCheckMode
{
get
;
set
; }
28
29
internal
EncryptionPolicy
EncryptionPolicy
{
get
;
set
; }
30
31
internal
bool
RemoteCertRequired
{
get
;
set
; }
32
33
internal
bool
CheckCertName
{
get
;
set
; }
34
35
internal
RemoteCertificateValidationCallback
CertValidationDelegate
{
get
;
set
; }
36
37
internal
LocalCertSelectionCallback
CertSelectionDelegate
{
get
;
set
; }
38
39
internal
ServerCertSelectionCallback
ServerCertSelectionDelegate
{
get
;
set
; }
40
41
internal
CipherSuitesPolicy
CipherSuitesPolicy
42
{
43
[
CompilerGenerated
]
44
set
45
{
46
_003CCipherSuitesPolicy_003Ek__BackingField
=
value
;
47
}
48
}
49
50
internal
object
UserState
{
get
; }
51
52
internal
ServerOptionsSelectionCallback
ServerOptionDelegate
{
get
; }
53
54
internal
SslAuthenticationOptions
(
SslClientAuthenticationOptions
sslClientAuthenticationOptions
, RemoteCertificateValidationCallback
remoteCallback
, LocalCertSelectionCallback
localCallback
)
55
{
56
AllowRenegotiation
=
sslClientAuthenticationOptions
.AllowRenegotiation;
57
ApplicationProtocols
=
sslClientAuthenticationOptions
.ApplicationProtocols;
58
CertValidationDelegate
=
remoteCallback
;
59
CheckCertName
=
true
;
60
EnabledSslProtocols
=
FilterOutIncompatibleSslProtocols
(
sslClientAuthenticationOptions
.EnabledSslProtocols);
61
EncryptionPolicy
=
sslClientAuthenticationOptions
.EncryptionPolicy;
62
IsServer
=
false
;
63
RemoteCertRequired
=
true
;
64
TargetHost
=
sslClientAuthenticationOptions
.TargetHost;
65
CertSelectionDelegate
=
localCallback
;
66
CertificateRevocationCheckMode
=
sslClientAuthenticationOptions
.CertificateRevocationCheckMode;
67
ClientCertificates
=
sslClientAuthenticationOptions
.ClientCertificates;
68
CipherSuitesPolicy
=
sslClientAuthenticationOptions
.CipherSuitesPolicy;
69
}
70
71
internal
SslAuthenticationOptions
(
SslServerAuthenticationOptions
sslServerAuthenticationOptions
)
72
{
73
AllowRenegotiation
=
sslServerAuthenticationOptions
.AllowRenegotiation;
74
ApplicationProtocols
=
sslServerAuthenticationOptions
.ApplicationProtocols;
75
CheckCertName
=
false
;
76
EnabledSslProtocols
=
FilterOutIncompatibleSslProtocols
(
sslServerAuthenticationOptions
.EnabledSslProtocols);
77
EncryptionPolicy
=
sslServerAuthenticationOptions
.EncryptionPolicy;
78
IsServer
=
true
;
79
RemoteCertRequired
=
sslServerAuthenticationOptions
.ClientCertificateRequired;
80
if
(
System
.
Net
.
NetEventSource
.
Log
.IsEnabled())
81
{
82
System
.
Net
.
NetEventSource
.
Info
(
this
,
$
"Server RemoteCertRequired: {RemoteCertRequired}."
,
".ctor"
);
83
}
84
TargetHost
=
string
.Empty;
85
CipherSuitesPolicy
=
sslServerAuthenticationOptions
.CipherSuitesPolicy;
86
CertificateRevocationCheckMode
=
sslServerAuthenticationOptions
.CertificateRevocationCheckMode;
87
if
(
sslServerAuthenticationOptions
.ServerCertificateContext !=
null
)
88
{
89
CertificateContext
=
sslServerAuthenticationOptions
.ServerCertificateContext;
90
}
91
else
if
(
sslServerAuthenticationOptions
.ServerCertificate !=
null
)
92
{
93
if
(
sslServerAuthenticationOptions
.ServerCertificate
is
X509Certificate2
{ HasPrivateKey: not false }
x509Certificate
)
94
{
95
CertificateContext
=
SslStreamCertificateContext
.
Create
(
x509Certificate
,
null
);
96
}
97
else
98
{
99
X509Certificate2
x509Certificate2
=
SecureChannel
.
FindCertificateWithPrivateKey
(
this
,
isServer
:
true
,
sslServerAuthenticationOptions
.ServerCertificate);
100
if
(
x509Certificate2
==
null
)
101
{
102
throw
new
AuthenticationException
(
System
.
SR
.
net_ssl_io_no_server_cert
);
103
}
104
CertificateContext
=
SslStreamCertificateContext
.
Create
(
x509Certificate2
);
105
}
106
}
107
if
(
sslServerAuthenticationOptions
.RemoteCertificateValidationCallback !=
null
)
108
{
109
CertValidationDelegate
=
sslServerAuthenticationOptions
.RemoteCertificateValidationCallback;
110
}
111
}
112
113
internal
SslAuthenticationOptions
(
ServerOptionsSelectionCallback
optionCallback
,
object
state
, RemoteCertificateValidationCallback
remoteCallback
)
114
{
115
CheckCertName
=
false
;
116
TargetHost
=
string
.Empty;
117
IsServer
=
true
;
118
UserState
=
state
;
119
ServerOptionDelegate
=
optionCallback
;
120
CertValidationDelegate
=
remoteCallback
;
121
}
122
123
internal
void
UpdateOptions
(
SslServerAuthenticationOptions
sslServerAuthenticationOptions
)
124
{
125
AllowRenegotiation
=
sslServerAuthenticationOptions
.AllowRenegotiation;
126
ApplicationProtocols
=
sslServerAuthenticationOptions
.ApplicationProtocols;
127
EnabledSslProtocols
=
FilterOutIncompatibleSslProtocols
(
sslServerAuthenticationOptions
.EnabledSslProtocols);
128
EncryptionPolicy
=
sslServerAuthenticationOptions
.EncryptionPolicy;
129
RemoteCertRequired
=
sslServerAuthenticationOptions
.ClientCertificateRequired;
130
CipherSuitesPolicy
=
sslServerAuthenticationOptions
.CipherSuitesPolicy;
131
CertificateRevocationCheckMode
=
sslServerAuthenticationOptions
.CertificateRevocationCheckMode;
132
if
(
sslServerAuthenticationOptions
.ServerCertificateContext !=
null
)
133
{
134
CertificateContext
=
sslServerAuthenticationOptions
.ServerCertificateContext;
135
}
136
else
if
(
sslServerAuthenticationOptions
.ServerCertificate
is
X509Certificate2
{ HasPrivateKey: not false }
x509Certificate
)
137
{
138
CertificateContext
=
SslStreamCertificateContext
.
Create
(
x509Certificate
);
139
}
140
if
(
sslServerAuthenticationOptions
.RemoteCertificateValidationCallback !=
null
)
141
{
142
CertValidationDelegate
=
sslServerAuthenticationOptions
.RemoteCertificateValidationCallback;
143
}
144
}
145
146
private
static
SslProtocols
FilterOutIncompatibleSslProtocols
(
SslProtocols
protocols
)
147
{
148
if
(
protocols
.HasFlag(
SslProtocols
.Tls12) ||
protocols
.HasFlag(
SslProtocols
.Tls13))
149
{
150
protocols
&=
~SslProtocols
.Ssl2;
151
}
152
return
protocols
;
153
}
154
}
System.Collections.Generic.Dictionary
Definition
Dictionary.cs:14
System.Net.NetEventSource.Log
static readonly System.Net.NetEventSource Log
Definition
NetEventSource.cs:20
System.Net.NetEventSource.Info
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
Definition
NetEventSource.cs:192
System.Net.NetEventSource
Definition
NetEventSource.cs:12
System.Net.Security.CipherSuitesPolicy
Definition
CipherSuitesPolicy.cs:6
System.Net.Security.SecureChannel.FindCertificateWithPrivateKey
static X509Certificate2 FindCertificateWithPrivateKey(object instance, bool isServer, X509Certificate certificate)
Definition
SecureChannel.cs:125
System.Net.Security.SecureChannel
Definition
SecureChannel.cs:13
System.Net.Security.SslAuthenticationOptions.IsServer
bool IsServer
Definition
SslAuthenticationOptions.cs:21
System.Net.Security.SslAuthenticationOptions.ServerOptionDelegate
ServerOptionsSelectionCallback ServerOptionDelegate
Definition
SslAuthenticationOptions.cs:52
System.Net.Security.SslAuthenticationOptions.ApplicationProtocols
List< SslApplicationProtocol > ApplicationProtocols
Definition
SslAuthenticationOptions.cs:19
System.Net.Security.SslAuthenticationOptions._003CCipherSuitesPolicy_003Ek__BackingField
CipherSuitesPolicy _003CCipherSuitesPolicy_003Ek__BackingField
Definition
SslAuthenticationOptions.cs:11
System.Net.Security.SslAuthenticationOptions.CertValidationDelegate
RemoteCertificateValidationCallback CertValidationDelegate
Definition
SslAuthenticationOptions.cs:35
System.Net.Security.SslAuthenticationOptions.ClientCertificates
X509CertificateCollection ClientCertificates
Definition
SslAuthenticationOptions.cs:17
System.Net.Security.SslAuthenticationOptions.TargetHost
string TargetHost
Definition
SslAuthenticationOptions.cs:15
System.Net.Security.SslAuthenticationOptions.CertificateContext
SslStreamCertificateContext CertificateContext
Definition
SslAuthenticationOptions.cs:23
System.Net.Security.SslAuthenticationOptions.CertSelectionDelegate
LocalCertSelectionCallback CertSelectionDelegate
Definition
SslAuthenticationOptions.cs:37
System.Net.Security.SslAuthenticationOptions.SslAuthenticationOptions
SslAuthenticationOptions(ServerOptionsSelectionCallback optionCallback, object state, RemoteCertificateValidationCallback remoteCallback)
Definition
SslAuthenticationOptions.cs:113
System.Net.Security.SslAuthenticationOptions.SslAuthenticationOptions
SslAuthenticationOptions(SslServerAuthenticationOptions sslServerAuthenticationOptions)
Definition
SslAuthenticationOptions.cs:71
System.Net.Security.SslAuthenticationOptions.UpdateOptions
void UpdateOptions(SslServerAuthenticationOptions sslServerAuthenticationOptions)
Definition
SslAuthenticationOptions.cs:123
System.Net.Security.SslAuthenticationOptions.SslAuthenticationOptions
SslAuthenticationOptions(SslClientAuthenticationOptions sslClientAuthenticationOptions, RemoteCertificateValidationCallback remoteCallback, LocalCertSelectionCallback localCallback)
Definition
SslAuthenticationOptions.cs:54
System.Net.Security.SslAuthenticationOptions.FilterOutIncompatibleSslProtocols
static SslProtocols FilterOutIncompatibleSslProtocols(SslProtocols protocols)
Definition
SslAuthenticationOptions.cs:146
System.Net.Security.SslAuthenticationOptions.AllowRenegotiation
bool AllowRenegotiation
Definition
SslAuthenticationOptions.cs:13
System.Net.Security.SslAuthenticationOptions.EnabledSslProtocols
SslProtocols EnabledSslProtocols
Definition
SslAuthenticationOptions.cs:25
System.Net.Security.SslAuthenticationOptions.UserState
object UserState
Definition
SslAuthenticationOptions.cs:50
System.Net.Security.SslAuthenticationOptions.CertificateRevocationCheckMode
X509RevocationMode CertificateRevocationCheckMode
Definition
SslAuthenticationOptions.cs:27
System.Net.Security.SslAuthenticationOptions.CheckCertName
bool CheckCertName
Definition
SslAuthenticationOptions.cs:33
System.Net.Security.SslAuthenticationOptions.RemoteCertRequired
bool RemoteCertRequired
Definition
SslAuthenticationOptions.cs:31
System.Net.Security.SslAuthenticationOptions.ServerCertSelectionDelegate
ServerCertSelectionCallback ServerCertSelectionDelegate
Definition
SslAuthenticationOptions.cs:39
System.Net.Security.SslAuthenticationOptions
Definition
SslAuthenticationOptions.cs:9
System.Net.Security.SslClientAuthenticationOptions
Definition
SslClientAuthenticationOptions.cs:8
System.Net.Security.SslServerAuthenticationOptions
Definition
SslServerAuthenticationOptions.cs:8
System.Net.Security.SslStreamCertificateContext.Create
static SslStreamCertificateContext Create(X509Certificate2 target, X509Certificate2Collection? additionalCertificates, bool offline)
Definition
SslStreamCertificateContext.cs:15
System.Net.Security.SslStreamCertificateContext
Definition
SslStreamCertificateContext.cs:7
System.SR.net_ssl_io_no_server_cert
static string net_ssl_io_no_server_cert
Definition
SR.cs:52
System.SR
Definition
SR.cs:7
System.Security.Authentication.AuthenticationException
Definition
AuthenticationException.cs:9
System.Security.Cryptography.X509Certificates.X509Certificate2
Definition
X509Certificate2.cs:13
System.Security.Cryptography.X509Certificates.X509CertificateCollection
Definition
X509CertificateCollection.cs:6
System.Collections.Generic
Definition
IHashKeyCollection.cs:1
System.Net.Security.EncryptionPolicy
EncryptionPolicy
Definition
EncryptionPolicy.cs:4
System.Net.Security.ServerOptionsSelectionCallback
delegate ValueTask< SslServerAuthenticationOptions > ServerOptionsSelectionCallback(SslStream stream, SslClientHelloInfo clientHelloInfo, object? state, CancellationToken cancellationToken)
System.Net.Security.ServerCertSelectionCallback
delegate X509Certificate ServerCertSelectionCallback(string hostName)
System.Net.Security
Definition
CertificateHelper.cs:4
System.Net
Definition
HttpClientJsonExtensions.cs:8
System.Runtime.CompilerServices
Definition
NullablePublicOnlyAttribute.cs:3
System.Security.Authentication.SslProtocols
SslProtocols
Definition
SslProtocols.cs:5
System.Security.Authentication
Definition
ExtendedProtectionPolicyTypeConverter.cs:8
System.Security.Cryptography.X509Certificates.X509RevocationMode
X509RevocationMode
Definition
X509RevocationMode.cs:4
System.Security.Cryptography.X509Certificates
Definition
CertificateAsn.cs:4
System.ExceptionArgument.value
@ value
System.ExceptionArgument.state
@ state
System
Definition
BlockingCollection.cs:8
source
System.Net.Security
System.Net.Security
SslAuthenticationOptions.cs
Generated by
1.10.0