On this page:
Listener
listen
Listener.close
Listener.accept
Listener.addresses
Listener.load_  certificate_  chain
Listener.load_  suggested_  certificate_  authorities
Listener.load_  private_  key

3 Secure Servers🔗ℹ

class

class ssl.Listener():

  constructor (

    ~host: host :: maybe(String) = #false,

    ~port: port :: network.ListenPortNumber,

    ~context: context :: ssl.Context.Server = ssl.Context.Server(),

    ~reuse: reuse :: Any = #false,

    ~max_allow_wait: max_allow_wait :: Nat = 5,

  ) :~ ssl.Listener

Implements an SSL server through an underlying TCP listener. The server is configured via context, while the reuse and max_allow_wait arguments are as for network.TCP.listen.

Call TCPListener.load_certificate_chain and TCPListener.load_private_key to avoid a “no shared cipher” error on accepting connections. The file whose path is collect.file_path(~collect: "openssl", ~file: "test.pem") is a suitable argument for both calls when testing. Since "test.pem" is public, however, such a test configuration obviously provides no security.

An SSL listener is a synchronizable event. It is ready—with itself as its value—when the underlying TCP listener is ready. At that point, however, accepting a connection with ssl.Listener.accept may not complete immediately, because further communication is needed to establish the connection.

An SSL listener implements Closeable, so it can be used with Closeable.let.

function

fun ssl.listen(

  ~host: host :: maybe(String) = #false,

  ~port: port :: network.ListenPortNumber,

  ~context: context :: ssl.Context.Server = ssl.Context.Server(),

  ~reuse: reuse :: Any = #false,

  ~max_allow_wait: max_allow_wait :: Nat = 5,

) :~ ssl.Listener

Analogous to network.TCP.listen, equivalent to constructing ssl.Listener.

method

method (lnr :: ssl.Listener).close()

Closes an SSL listener. Closing the listener means that no new connections can be accepted, but existing connections can continue.

method

method (lnr :: ssl.Listener).accept(

  ~wait: wait :: network.NetworkWait = #'all

) :: values(ssl.Port.Input, ssl.Port.Output)

Analogous to network.TCPListener.accept, accepts an SSL client connection for a server’s listener.

method

method (lnr :: ssl.Listener).addresses()

  :: values(String, network.PortNumber)

Like network.TCPListener.addresses.

method

method (lnr :: ssl.Listener).load_certificate_chain(

  path :: PathString

)

 

method

method (lnr :: ssl.Listener)

  .load_suggested_certificate_authorities(path :: PathString)

 

method

method (lnr :: ssl.Listener).load_private_key(

  key :: PathString || ssl.Context.PrivateKey,

  ~kind: kind :: ssl.Context.KeyKind = #'rsa

)

These methods are like ssl.Context.load_certificate_chain, ssl.Context.load_suggested_certificate_authorities, and ssl.Context.load_private_key, but for an already-created SSL listener.