public void AuthenticateAsClient(string host) { if (tlsStreams != null) { throw new InvalidOperationException("TLS has already been activated on this Socket."); } try { Socket.Blocking = true; tlsStreams = new SocketTlsStreams(Socket); tlsStreams.SslStream.AuthenticateAsClient(host); SendQueue(); } catch (Exception ex) { OnException(ex); } }
public void AuthenticateAsServer(X509Certificate certificate) { if (certificate == null) { throw new ArgumentNullException("certificate"); } if (tlsStreams != null) { throw new InvalidOperationException("TLS has already been activated on this Socket."); } try { Socket.Blocking = true; tlsStreams = new SocketTlsStreams(Socket); tlsStreams.SslStream.AuthenticateAsServer(certificate); SendQueue(); } catch (Exception ex) { OnException(ex); } }