Future<RawSecureSocket> secureServer(RawSocket socket, SecurityContext context, { StreamSubscription<RawSocketEvent> subscription, 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 RawSecureSocket 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, pass the existing subscription in the subscription parameter. The secureServer operation will take over the subscription by replacing the handlers with it own secure processing. The caller must not touch this subscription anymore. Passing a paused subscription is an error.

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 RawSecureServerSocket.bind for more information on the arguments.

Source

static Future<RawSecureSocket> secureServer(
    RawSocket socket,
    SecurityContext context,
    {StreamSubscription<RawSocketEvent> subscription,
     List<int> bufferedData,
     bool requestClientCertificate: false,
     bool requireClientCertificate: false,
     List<String> supportedProtocols}) {
  socket.readEventsEnabled = false;
  socket.writeEventsEnabled = false;
  return _RawSecureSocket.connect(
      socket.address,
      socket.remotePort,
      context: context,
      is_server: true,
      socket: socket,
      subscription: subscription,
      bufferedData: bufferedData,
      requestClientCertificate: requestClientCertificate,
      requireClientCertificate: requireClientCertificate,
      supportedProtocols: supportedProtocols);
}