pub struct TlsServer { /* private fields */ }Expand description
A TLS server address under construction, returned by Server::tls.
Carries the options that only make sense for a TLS connection. Convert it
into a Server with From — which happens automatically wherever an
impl Into<Server> is accepted, so the builder chain can be passed directly
to connect.
Implementations§
Source§impl TlsServer
impl TlsServer
Sourcepub fn with_sni(self, hostname: impl Into<String>) -> Self
pub fn with_sni(self, hostname: impl Into<String>) -> Self
Override the hostname used for SNI and certificate verification.
By default the host part of the address is used. Set this when connecting to an IP address whose certificate names a hostname, or when going through a tunnel that changes the address.
Sourcepub fn with_extra_root_pem(self, pem: impl Into<Vec<u8>>) -> Self
pub fn with_extra_root_pem(self, pem: impl Into<Vec<u8>>) -> Self
Trust an additional root certificate, in PEM form, alongside the platform’s native roots.
This is the supported way to connect to a network using a private CA or a self-signed certificate: trust exactly that certificate rather than disabling verification wholesale. May be called repeatedly; every certificate found in each PEM blob is added.
The PEM is parsed when the connection is made, so a malformed blob surfaces as a connect error rather than a panic here.
Sourcepub fn with_client_cert_pem(self, pem: impl Into<Vec<u8>>) -> Self
pub fn with_client_cert_pem(self, pem: impl Into<Vec<u8>>) -> Self
Present a client certificate, in PEM form, for CertFP / SASL EXTERNAL authentication.
pem must contain the private key and the certificate chain
concatenated — the single-file form produced by, for example:
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 \
-nodes -keyout bot.pem -out bot.pem -subj "/CN=mybot"The bytes are parsed when the connection is made, so a malformed or key-less blob surfaces as a connect error rather than a panic here.
Calling this more than once replaces the previous certificate.
Sourcepub fn danger_accept_invalid_certs(self) -> Self
pub fn danger_accept_invalid_certs(self) -> Self
Dangerous. Accept any server certificate without verifying it.
This disables certificate and hostname verification entirely, which
removes the protection TLS provides against an active
machine-in-the-middle: traffic is still encrypted, but you have no
assurance about who it is encrypted to. Passwords sent to the server —
PASS, NickServ IDENTIFY, SASL — become interceptable.
It exists for talking to a development server on localhost and for
tests. For a real network using a self-signed or private-CA
certificate, use with_extra_root_pem
instead: it keeps verification on and trusts exactly the one certificate
you intend to trust.
Enabling this logs a warning on every connection.