SSL/TLS Certificate validation

XMPP is using TLS to encrypt the XML stream. With the Tls property of the XMPP client you can control the encryption settings. By default it is set to true and automatically enabled when supported by the target server. We do not recommend to disable Tls in any of your production code.

SSL/TLS Certificate

TLS is based on certificates. When the stream gets updated to TLS then the server presents a certificate to the client. The .NET Framework and XmppDotNet automatically validates the certificate. When there are any validation errors XmppDotNet will not proceed during TLS negotiation and terminate the stream.

However in some deployments, testing or staging environments you may have invalid, self signed or untrusted certificates, and still want to secure the connection using TLS.

Here is an example where an AlwaysAcceptCertificateValidator is used to ignore all errors and trusts blindly all certificates.

Example


var xmppClient = new XmppClient(
    conf =>
    {
        conf
            .UseSocketTransport()
            .WithCertificateValidator(new AlwaysAcceptCertificateValidator());
    },
    (handlers, client) => handlers.Add(new XmppLoggingHandler(client)))
{
    Jid = "user@server.com",
    Password = "secret"
};

await xmppClient.ConnectAsync();