Skip to content

SSLContext

[Source]

An SSL context is used to create SSL sessions.

class val SSLContext

Constructors

create

[Source]

Create an SSL context.

new ref create()
: SSLContext ref^

Returns


Public Functions

client

[Source]

Create a client-side SSL session. If a hostname is supplied, the server side certificate must be valid for that hostname.

fun box client(
  hostname: String val = "")
: SSL iso^ ?

Parameters

Returns


server

[Source]

Create a server-side SSL session.

fun box server()
: SSL iso^ ?

Returns


set_cert

[Source]

The cert file is a PEM certificate chain. The key file is a private key. Servers must set this. For clients, it is optional.

fun ref set_cert(
  cert: FilePath val,
  key: FilePath val)
: None val ?

Parameters

Returns


set_authority

[Source]

Use a PEM file and/or a directory of PEM files to specify certificate authorities. Clients must set this. For servers, it is optional. Use None to indicate no file or no path. Raises an error if these verify locations aren't valid.

If both file and path are None, on Windows this method loads the system root certificates. On Posix it raises an error.

fun ref set_authority(
  file: (FilePath val | None val),
  path: (FilePath val | None val) = reference)
: None val ?

Parameters

Returns


set_ciphers

[Source]

Set the accepted ciphers. This replaces the existing list. Raises an error if the cipher list is invalid.

fun ref set_ciphers(
  ciphers: String val)
: None val ?

Parameters

Returns


set_client_verify

[Source]

Set to true to require verification. Defaults to true.

fun ref set_client_verify(
  state: Bool val)
: None val

Parameters

Returns


set_server_verify

[Source]

Set to true to require verification. Defaults to false.

fun ref set_server_verify(
  state: Bool val)
: None val

Parameters

Returns


set_verify_depth

[Source]

Set the verify depth. Defaults to 6.

fun ref set_verify_depth(
  depth: U32 val)
: None val

Parameters

  • depth: U32 val

Returns


set_min_proto_version

[Source]

Set minimum protocol version. Set to SslAutoVersion, 0, to automatically manage lowest version.

Supported versions: Ssl3Version, Tls1Version, Tls1u1Version, Tls1u2Version, Tls1u3Version, Dtls1Version, Dtls1u2Version

fun ref set_min_proto_version(
  version: ULong val)
: None val ?

Parameters

Returns


get_min_proto_version

[Source]

Get minimum protocol version. Returns SslAutoVersion, 0, when automatically managing lowest version.

Supported versions: Ssl3Version, Tls1Version, Tls1u1Version, Tls1u2Version, Tls1u3Version, Dtls1Version, Dtls1u2Version

fun ref get_min_proto_version()
: ILong val

Returns


set_max_proto_version

[Source]

Set maximum protocol version. Set to SslAutoVersion, 0, to automatically manage higest version.

Supported versions: Ssl3Version, Tls1Version, Tls1u1Version, Tls1u2Version, Tls1u3Version, Dtls1Version, Dtls1u2Version

fun ref set_max_proto_version(
  version: ULong val)
: None val ?

Parameters

Returns


get_max_proto_version

[Source]

Get maximum protocol version. Returns SslAutoVersion, 0, when automatically managing highest version.

Supported versions: Ssl3Version, Tls1Version, Tls1u1Version, Tls1u2Version, Tls1u3Version, Dtls1Version, Dtls1u2Version

fun ref get_max_proto_version()
: ILong val

Returns


alpn_set_resolver

[Source]

Use resolver to choose the protocol to be selected for incomming connections.

Returns true on success Requires OpenSSL >= 1.0.2

fun ref alpn_set_resolver(
  resolver: ALPNProtocolResolver box)
: Bool val

Parameters

Returns


alpn_set_client_protocols

[Source]

Configures the SSLContext to advertise the protocol names defined in protocols when connecting to a server protocol names must have a size of 1 to 255

Returns true on success Requires OpenSSL >= 1.0.2

fun ref alpn_set_client_protocols(
  protocols: Array[String val] box)
: Bool val

Parameters

Returns


allow_tls_v1

[Source]

Allow TLS v1. Defaults to false. Deprecated: use set_min_proto_version and set_max_proto_version

fun ref allow_tls_v1(
  state: Bool val)
: None val

Parameters

Returns


allow_tls_v1_1

[Source]

Allow TLS v1.1. Defaults to false. Deprecated: use set_min_proto_version and set_max_proto_version

fun ref allow_tls_v1_1(
  state: Bool val)
: None val

Parameters

Returns


allow_tls_v1_2

[Source]

Allow TLS v1.2. Defaults to true. Deprecated: use set_min_proto_version and set_max_proto_version

fun ref allow_tls_v1_2(
  state: Bool val)
: None val

Parameters

Returns


dispose

[Source]

Free the SSL context.

fun ref dispose()
: None val

Returns