data TLS::ServerConfig(certificate: Bytes, private_key: Bytes, alpn: Array[String], min_version: Symbol)

What a server presents and offers: its certificate chain and private key (PEM), the protocols it accepts by ALPN, the oldest version. Immutable, so one config serves any number of connections and tasks; the configuration built from it is kept, with its cache of sessions to resume (rustls's default). Client certificates, OCSP stapling and settings for resumption are not supported yet.

Its inspect and to_s never show the private key.

config = TLS::ServerConfig.new(certificate: File.read("server.pem"),
                               private_key: File.read("server.key"),
                               alpn: ["http/1.1"])

<std:tls>:155

Class methods

def self.new(*, certificate: Bytes | String, private_key: Bytes | String, alpn: Array[String] = …, min_version: Symbol = …) -> TLS::ServerConfig

Raises TLS::Error when the certificate or the key does not parse, or the key is not the certificate's; the message names which.

<std:tls>:168

Methods

def certificate -> Bytes

The certificate chain (PEM), the server's own certificate first.

<std:tls>:157

def private_key -> Bytes

The private key of the certificate (PEM: PKCS#8, PKCS#1 or SEC1).

<std:tls>:159

def alpn -> Array[String]

The protocols accepted by ALPN, preferred first; a client offering none of them is refused, one offering none is served.

<std:tls>:162

def min_version -> Symbol

The oldest version accepted: :tls12 or :tls13.

<std:tls>:164

def to_h -> Hash[Symbol, Object]

The fields as a Hash, by name.

<std:tls>:168

def accept(socket: TCPSocket) -> TLSSocket

Runs the TLS handshake as the server on socket: TLSSocket.accept.

<std:tls>:181

def inspect -> String

The config, its private key hidden.

<std:tls>:184

def to_s -> String

The config, its private key hidden.

<std:tls>:190