【发布时间】:2016-01-26 22:42:14
【问题描述】:
我正在使用以下代码连接到主机:
protected bool OpenSocket(string hostIPAddress, int hostIPPort)
{
try
{
if ((this._tcpSocket != null) && (this._tcpSocket.Connected == true))
return (true);
}
catch { }
// Reset variables
this._isSocketOpen = false;
this._isSSLOpen = false;
string ipAddress = this.GetHostIPAddress(hostIPAddress);
this._tcpSocket = new TcpClient(ipAddress, hostIPPort);
this._tcpipConnectionStream = this._tcpSocket.GetStream();
this._isSocketOpen = true;
return true;
}
在连接到主机时,有什么方法可以确定 SSL 连接类型(即 SSL2、SSL3、TL1.2)吗?我已经研究过使用这样的东西:
SslStream sslStream = new SslStream(this._tcpSocket.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null);
sslStream.AuthenticateAsClient(hostIPAddress);
但是我认为这将用于设置 SSL 协议不是吗,而不是获取它?我很迷茫。
【问题讨论】:
-
您发布的代码是否足以创建与主机的 SSL 连接?这是你要找的,还是我想念你理解你
-
另请参阅此链接,它可能会有所帮助stackoverflow.com/questions/252365
-
@Hakem Fostok。我只想知道建立连接后的连接类型是什么