private async Task <bool> AuthAsync(PooledSocket socket) { SaslStep currentStep = new SaslStart(this.authenticationProvider); await socket.WriteAsync(currentStep.GetBuffer()); while (!(await currentStep.ReadResponseAsync(socket)).Success) { // challenge-response authentication if (currentStep.StatusCode == 0x21) { currentStep = new SaslContinue(this.authenticationProvider, currentStep.Data); await socket.WriteAsync(currentStep.GetBuffer()); } else { _logger.LogWarning("Authentication failed, return code: 0x{0:x}", currentStep.StatusCode); // invalid credentials or other error return(false); } } return(true); }