private async Task EncryptStream()

in src/DotPulsar/Internal/Connector.cs [88:113]


    private async Task<Stream> EncryptStream(Stream stream, string host)
    {
        SslStream? sslStream = null;

        try
        {
            sslStream = new SslStream(stream, false, ValidateServerCertificate, null);
            await sslStream.AuthenticateAsClientAsync(host, _clientCertificates, SslProtocols.None, _checkCertificateRevocation).ConfigureAwait(false);
            return sslStream;
        }
        catch
        {
#if NETSTANDARD2_0
            if (sslStream is null)
                stream.Dispose();
            else
                sslStream.Dispose();
#else
            if (sslStream is null)
                await stream.DisposeAsync().ConfigureAwait(false);
            else
                await sslStream.DisposeAsync().ConfigureAwait(false);
#endif
            throw;
        }
    }