description

# secureServer static method

Future<SecureSocket> secureServer(

1. Socket socket,
2. SecurityContext? context, {
3. List<int>? bufferedData,
4. bool requestClientCertificate = false,
5. bool requireClientCertificate = false,
6. List<String>? supportedProtocols,

})

Initiates TLS on an existing server connection.

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 StreamSubscription.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.

## Implementation

    static Future<SecureSocket> secureServer(
      Socket socket,
      SecurityContext? context, {
      List<int>? bufferedData,
      bool requestClientCertificate = false,
      bool requireClientCertificate = false,
      List<String>? supportedProtocols,
    }) {
      return socket
          ._detachRaw()
          .then<RawSecureSocket>((detachedRaw) {
            return RawSecureSocket.secureServer(
              detachedRaw[0] as RawSocket,
              context,
              subscription: detachedRaw[1] as StreamSubscription<RawSocketEvent>?,
              bufferedData: bufferedData,
              requestClientCertificate: requestClientCertificate,
              requireClientCertificate: requireClientCertificate,
              supportedProtocols: supportedProtocols,
            );
          })
          .then<SecureSocket>((raw) => SecureSocket._(raw));
    }