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"])
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.
Methods
def certificate -> Bytes
The certificate chain (PEM), the server's own certificate first.
def private_key -> Bytes
The private key of the certificate (PEM: PKCS#8, PKCS#1 or SEC1).
def alpn -> Array[String]
The protocols accepted by ALPN, preferred first; a client offering none of them is refused, one offering none is served.
def min_version -> Symbol
The oldest version accepted: :tls12 or :tls13.
def to_h -> Hash[Symbol, Object]
The fields as a Hash, by name.
def accept(socket: TCPSocket) -> TLSSocket
Runs the TLS handshake as the server on socket: TLSSocket.accept.
def inspect -> String
The config, its private key hidden.
def to_s -> String
The config, its private key hidden.