StreamPeerSSL

Inherits: StreamPeer < RefCounted < Object

SSL stream peer.

Description

SSL stream peer. This object can be used to connect to an SSL server or accept a single SSL 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

Properties

bool

blocking_handshake

true

Methods

Error

accept_stream ( StreamPeer stream, CryptoKey private_key, X509Certificate certificate, X509Certificate chain=null )

Error

connect_to_stream ( StreamPeer stream, bool validate_certs=false, String for_hostname="", X509Certificate valid_certificate=null )

void

disconnect_from_stream ( )

Status

get_status ( ) const

StreamPeer

get_stream ( ) const

void

poll ( )

Enumerations

enum Status:

  • STATUS_DISCONNECTED = 0 --- A status representing a StreamPeerSSL that is disconnected.

  • STATUS_HANDSHAKING = 1 --- A status representing a StreamPeerSSL during handshaking.

  • STATUS_CONNECTED = 2 --- A status representing a StreamPeerSSL that is connected to a host.

  • STATUS_ERROR = 3 --- A status representing a StreamPeerSSL in error state.

  • STATUS_ERROR_HOSTNAME_MISMATCH = 4 --- An error status that shows a mismatch in the SSL certificate domain presented by the host and the domain requested for validation.

Property Descriptions

  • bool blocking_handshake

Default

true

Setter

set_blocking_handshake_enabled(value)

Getter

is_blocking_handshake_enabled()

Method Descriptions

Accepts a peer connection as a server using the given private_key and providing the given certificate to the client. You can pass the optional chain parameter to provide additional CA chain information along with the certificate.


Connects to a peer using an underlying StreamPeer stream. If validate_certs is true, StreamPeerSSL will validate that the certificate presented by the peer matches the for_hostname.

Note: Specifying a custom valid_certificate is not supported in HTML5 exports due to browsers restrictions.


  • void disconnect_from_stream ( )

Disconnects from host.


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


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.