Attention

You are reading the latest (unstable) version of this documentation, which may document features not available or compatible with Godot 3.x.

Work in progress

Godot documentation is being updated to reflect the latest changes in version 4.0. Some documentation pages may still state outdated information. This banner will tell you if you're reading one of such pages.

The contents of this page are up to date. If you can still find outdated information, please open an issue.

StreamPeerTLS

Inherits: StreamPeer < RefCounted < Object

TLS stream peer.

Description

TLS stream peer. This object can be used to connect to an TLS server or accept a single TLS client connection.

Note: When exporting to Android, make sure to enable the INTERNET permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.

Tutorials

Methods

Error

accept_stream ( StreamPeer stream, TLSOptions server_options )

Error

connect_to_stream ( StreamPeer stream, String common_name, TLSOptions client_options=null )

void

disconnect_from_stream ( )

Status

get_status ( ) const

StreamPeer

get_stream ( ) const

void

poll ( )


Enumerations

enum Status:

Status STATUS_DISCONNECTED = 0

A status representing a StreamPeerTLS that is disconnected.

Status STATUS_HANDSHAKING = 1

A status representing a StreamPeerTLS during handshaking.

Status STATUS_CONNECTED = 2

A status representing a StreamPeerTLS that is connected to a host.

Status STATUS_ERROR = 3

A status representing a StreamPeerTLS in error state.

Status STATUS_ERROR_HOSTNAME_MISMATCH = 4

An error status that shows a mismatch in the TLS certificate domain presented by the host and the domain requested for validation.


Method Descriptions

Error accept_stream ( StreamPeer stream, TLSOptions server_options )

Accepts a peer connection as a server using the given server_options. See TLSOptions.server.


Error connect_to_stream ( StreamPeer stream, String common_name, TLSOptions client_options=null )

Connects to a peer using an underlying StreamPeer stream and verifying the remote certificate is correctly signed for the given common_name. You can pass the optional client_options parameter to customize the trusted certification authorities, or disable the common name verification. See TLSOptions.client and TLSOptions.client_unsafe.


void disconnect_from_stream ( )

Disconnects from host.


Status get_status ( ) const

Returns the status of the connection. See Status for values.


StreamPeer get_stream ( ) const

Returns the underlying StreamPeer connection, used in accept_stream or connect_to_stream.


void poll ( )

Poll the connection to check for incoming bytes. Call this right before StreamPeer.get_available_bytes for it to work properly.