Future<SecureSocket> secureServer(
Socket socket,
String certificateName,
{List<int> bufferedData,
bool requestClientCertificate: false,
bool requireClientCertificate: false,
List<String> supportedProtocols}
)

Takes an already connected socket and starts server side TLS handshake to make the communication secure. When the returned future completes the SecureSocket has completed the TLS handshake. Using this function requires that the other end of the connection is going to start the TLS handshake.

If the socket already has a subscription, this subscription will no longer receive and events. In most cases calling pause on this subscription before starting TLS handshake is the right thing to do.

If some of the data of the TLS handshake has already been read from the socket this data can be passed in the bufferedData parameter. This data will be processed before any other data available on the socket.

See SecureServerSocket.bind for more information on the arguments.

Source

/**
 * Takes an already connected [socket] and starts server side TLS
 * handshake to make the communication secure. When the returned
 * future completes the [SecureSocket] has completed the TLS
 * handshake. Using this function requires that the other end of the
 * connection is going to start the TLS handshake.
 *
 * If the [socket] already has a subscription, this subscription
 * will no longer receive and events. In most cases calling
 * [:pause:] on this subscription before starting TLS handshake is
 * the right thing to do.
 *
 * If some of the data of the TLS handshake has already been read
 * from the socket this data can be passed in the [bufferedData]
 * parameter. This data will be processed before any other data
 * available on the socket.
 *
 * See [SecureServerSocket.bind] for more information on the
 * arguments.
 *
 */
static Future<SecureSocket> secureServer(
    Socket socket,
    String certificateName,
    {List<int> bufferedData,
     bool requestClientCertificate: false,
     bool requireClientCertificate: false,
     List<String> supportedProtocols}) {
  var completer = new Completer();
  (socket as dynamic)._detachRaw()
      .then((detachedRaw) {
        return RawSecureSocket.secureServer(
          detachedRaw[0],
          certificateName,
          subscription: detachedRaw[1],
          bufferedData: bufferedData,
          requestClientCertificate: requestClientCertificate,
          requireClientCertificate: requireClientCertificate,
          supportedProtocols: supportedProtocols);
        })
      .then((raw) {
        completer.complete(new SecureSocket._(raw));
      });
  return completer.future;
}