本文整理汇总了C#中System.Net.Security.SslStream.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# SslStream.GetHashCode方法的具体用法?C# SslStream.GetHashCode怎么用?C# SslStream.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Security.SslStream
的用法示例。
在下文中一共展示了SslStream.GetHashCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//.........这里部分代码省略.........
checkCertificateRevocation: false
);
var RemoteCertificate = sslStream.RemoteCertificate;
Console.WriteLine(new { RemoteCertificate });
}
catch (Exception ex)
{
Console.WriteLine(new { ex.Message });
if (ex.InnerException != null)
Console.WriteLine(new { ex.InnerException.Message });
return;
}
// ... Send and read data over the stream
// NET::ERR_CERT_AUTHORITY_INVALID
// issue NIC private key pfx?
// Error code: ERR_CONNECTION_REFUSED
// Your connection is not private
// NET::ERR_CERT_AUTHORITY_INVALID
//var x = sslStream.ReadByte();
Console.WriteLine("read " + sslStream.GetHashCode());
//read 1707556
//read 15368010
//read 4094363
//GET / HTTP/1.1
//Host: localhost:1300
//Connection: keep-alive
//Cache-Control: max-age=0
//Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
//User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2188.2 Safari/537.36
//Accept-Encoding: gzip, deflate, sdch
//Accept-Language: en-US,en;q=0.8
// Additional information: Stream was not readable.
#region 200
var rx = new StreamReader(sslStream);
Action y = delegate { };
while (true)
{
var rxl = rx.ReadLine();
if (string.IsNullOrEmpty(rxl))
break;
Console.WriteLine(rxl);
if (rxl == "GET / HTTP/1.1")
y = delegate
{
// Error code: ERR_EMPTY_RESPONSE
示例2: Main
//.........这里部分代码省略.........
//}
//);
};
}
y();
};
#endregion
if (zbuffer[0] == 0x47)
{
Console.WriteLine("enter http");
x200(p);
p.Close();
Console.WriteLine("exit http");
return;
}
if (zbuffer[0] == 0x16)
{
Console.WriteLine("enter https");
X509Certificate2 xcertificate = new X509Certificate2(@"X:\jsc.svn\examples\java\hybrid\JVMCLRSSLTCPListener\JVMCLRSSLTCPListener\bin\Debug\serverCert.cer.pfx", "xxx");
using (SslStream sslStream = new SslStream(
innerStream: p,
leaveInnerStreamOpen: false,
userCertificateSelectionCallback:
new LocalCertificateSelectionCallback(
(object sender, string targetHost, X509CertificateCollection localCertificates, X509Certificate remoteCertificate, string[] acceptableIssuers) =>
{
return localCertificates[0];
}
),
userCertificateValidationCallback:
new RemoteCertificateValidationCallback(
(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) =>
{
Console.WriteLine(
new { certificate }
);
return true;
}
),
encryptionPolicy: EncryptionPolicy.RequireEncryption
))
{
try
{
// AuthenticateAsServer
// can this hang? if we use the wrong stream!
sslStream.AuthenticateAsServer(
serverCertificate: CertificateFromCurrentUserByLocalEndPoint((IPEndPoint)clientSocket.Client.LocalEndPoint),
//clientCertificateRequired: false,
clientCertificateRequired: true,
// chrome for android does not like IIS TLS 1.2
enabledSslProtocols: System.Security.Authentication.SslProtocols.Tls12,
checkCertificateRevocation: false
);
}
catch (Exception ex)
{
Console.WriteLine(new { ex.Message });
if (ex.InnerException != null)
Console.WriteLine(new { ex.InnerException.Message });
return;
}
Console.WriteLine("read " + sslStream.GetHashCode());
x200(sslStream);
sslStream.Close();
}
Console.WriteLine("exit https");
return;
}
Console.WriteLine("exit other");
p.Close();
};
while (true)
yield(
listener.AcceptTcpClient()
);
CLRProgram.CLRMain();
}