Validate that base stream is valid before accepting/connecting. Also remove unnecessary includes.
connect_to_stream now accepts optional parameter to specify which certificates to trust. Implement accept_stream (SSL server) with key/cert parameters to specify the RSA key and X509 certificate resources.