SslApplicationProtocol Yapı
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
TLS Uygulama protokolünün değerini temsil eder.
public value class SslApplicationProtocol : IEquatable<System::Net::Security::SslApplicationProtocol>
public readonly struct SslApplicationProtocol : IEquatable<System.Net.Security.SslApplicationProtocol>
type SslApplicationProtocol = struct
Public Structure SslApplicationProtocol
Implements IEquatable(Of SslApplicationProtocol)
- Devralma
- Uygulamalar
Örnekler
Aşağıdaki kod örneğinde üzerinde SslStreamuygulama düzeyi protokolü anlaşması gösterilmektedir. Sunucu ve protocol2için protocol1 desteği tanıtıyor. İstemci ve protocol3için protocol2 desteği tanıtıyor. El sıkışma sırasında yaygın olarak desteklenen protokol (protocol2) anlaşması yapılır.
async Task Server(NetworkStream stream, X509Certificate2 serverCertificate)
{
using var server = new SslStream(stream);
await server.AuthenticateAsServerAsync(new SslServerAuthenticationOptions
{
ServerCertificate = serverCertificate,
ApplicationProtocols = new()
{
new("protocol1"),
new("protocol2"),
}
});
string protocol = Encoding.ASCII.GetString(server.NegotiatedApplicationProtocol.Protocol.Span);
System.Console.WriteLine($"Server - negotiated protocol: {protocol}");
}
async Task Client(NetworkStream stream, string hostName)
{
using var client = new SslStream(stream);
await client.AuthenticateAsClientAsync(new SslClientAuthenticationOptions
{
// the host name must match the name on the certificate used on the server side
TargetHost = hostName,
ApplicationProtocols = new()
{
new("protocol2"),
new("protocol3")
}
});
string protocol = Encoding.ASCII.GetString(client.NegotiatedApplicationProtocol.Protocol.Span);
System.Console.WriteLine($"Client - negotiated protocol: {protocol}");
}
// possible output:
// Server - negotiated protocol: protocol2
// Client - negotiated protocol: protocol2
Async Function Server(stream As NetworkStream, serverCertificate As X509Certificate2) As Task
Using serverStream As SslStream = new SslStream(stream)
Dim options as New SslServerAuthenticationOptions() With
{
.ServerCertificate = serverCertificate,
.ApplicationProtocols = New List(Of SslApplicationProtocol) From
{
New SslApplicationProtocol("protocol1"),
New SslApplicationProtocol("protocol2")
}
}
Await serverStream.AuthenticateAsServerAsync(options)
Dim protocol As String = Encoding.ASCII.GetString(
serverStream.NegotiatedApplicationProtocol.Protocol.Span)
System.Console.WriteLine($"Server - negotiated protocol: {protocol}")
End Using
End Function
Async Function Client(stream As NetworkStream, hostName As String ) As Task
Using clientStream As SslStream = new SslStream(stream)
Dim options as New SslClientAuthenticationOptions() With
{
.TargetHost = hostName,
.ApplicationProtocols = New List(Of SslApplicationProtocol) From
{
New SslApplicationProtocol("protocol2"),
New SslApplicationProtocol("protocol3")
}
}
Await clientStream.AuthenticateAsClientAsync(options)
Dim protocol As String = Encoding.ASCII.GetString(
clientStream.NegotiatedApplicationProtocol.Protocol.Span)
System.Console.WriteLine($"Client - negotiated protocol: {protocol}")
End Using
End Function
' possible output:
' Server - negotiated protocol: protocol2
' Client - negotiated protocol: protocol2
Açıklamalar
Bu tür, HTTP sürümleri için önceden tanımlanmış SslApplicationProtocol değerler içeren statik alanlar içerir.
El sıkışma sırasında istemci kullanılabilir ALPN protokollerinin listesini gönderir ve sunucu bu listeden en iyi eşleşmeyi seçer.
Desteklenen protokollerin tam listesi için bkz. TLS Application-Layer Protokol Anlaşması (ALPN) Protokol Kimlikleri.
Oluşturucular
| Name | Description |
|---|---|
| SslApplicationProtocol(Byte[]) |
öğesinin yeni bir örneğini SslApplicationProtocolbaşlatır. |
| SslApplicationProtocol(String) |
öğesinin yeni bir örneğini SslApplicationProtocolbaşlatır. |
Alanlar
| Name | Description |
|---|---|
| Http11 |
Temsil eden bir SslApplicationProtocol HTTP/1.1 TLS uygulama protokolü alır. |
| Http2 |
Temsil eden bir SslApplicationProtocol HTTP/2 TLS uygulama protokolü alır. |
Özellikler
| Name | Description |
|---|---|
| Protocol |
Bu SslApplicationProtocoltarafından temsil edilen geçerli bir TLS uygulama protokolü alır. |
Yöntemler
| Name | Description |
|---|---|
| Equals(Object) |
öğesini SslApplicationProtocol belirtilen nesneyle karşılaştırır. |
| Equals(SslApplicationProtocol) |
a SslApplicationProtocol değerini belirtilen SslApplicationProtocol örnekle karşılaştırır. |
| GetHashCode() |
Örneğin karma kodunu SslApplicationProtocol döndürür. |
| ToString() |
ToString() yöntemini geçersiz kılar. |
İşleçler
| Name | Description |
|---|---|
| Equality(SslApplicationProtocol, SslApplicationProtocol) |
İki SslApplicationProtocol nesneyi karşılaştırmak için eşitlik işleci. |
| Inequality(SslApplicationProtocol, SslApplicationProtocol) |
İki SslApplicationProtocol nesneyi karşılaştırmak için eşitsizlik işleci. |