protected async Task EvaluateMxRecordProfile(MxRecordTlsProfile mxRecordTlsProfile) { if (mxRecordTlsProfile.MxHostname == null) { await _tlsRecordDao.SaveTlsEvaluatorResults(mxRecordTlsProfile, EvaluatorResults.EmptyResults); _log.Debug( $"MX record with ID {mxRecordTlsProfile.MxRecordId} has no hostname, saving null results."); } else { string failedConnectionErrors = mxRecordTlsProfile.ConnectionResults.GetFailedConnectionErrors(); if (string.IsNullOrWhiteSpace(failedConnectionErrors)) { var tlsEvaluatorResults = _mxSecurityEvaluator.Evaluate(mxRecordTlsProfile.ConnectionResults); await _tlsRecordDao.SaveTlsEvaluatorResults(mxRecordTlsProfile, tlsEvaluatorResults); _log.Debug( $"Evaluated TLS connection results for MX record with ID {mxRecordTlsProfile.MxRecordId}."); } else { await _tlsRecordDao.SaveTlsEvaluatorResults(mxRecordTlsProfile, EvaluatorResults.GetConnectionFailedResults(failedConnectionErrors)); _log.Debug( $"MX record with ID {mxRecordTlsProfile.MxRecordId} TLS connection failed, saving single inconclusive result."); } } }
protected Task EvaluateMxRecordProfile(MxRecordTlsProfile mxRecordTlsProfile) { if (mxRecordTlsProfile.MxHostname == null) { _log.Debug($"No hostname for MX record with ID {mxRecordTlsProfile.MxRecordId}."); return(_tlsRecordDao.SaveTlsEvaluatorResults(mxRecordTlsProfile, EvaluatorResults.EmptyResults)); } if (mxRecordTlsProfile.ConnectionResults.HasFailedConnection()) { _log.Debug($"TLS connection failed for host {mxRecordTlsProfile.MxHostname}"); string failedConnectionErrors = mxRecordTlsProfile.ConnectionResults.GetFailedConnectionErrors(); return(_tlsRecordDao.SaveTlsEvaluatorResults(mxRecordTlsProfile, EvaluatorResults.GetConnectionFailedResults(failedConnectionErrors))); } if (mxRecordTlsProfile.ConnectionResults.HostNotFound()) { _log.Debug($"Host not found for {mxRecordTlsProfile.MxHostname}"); return(_tlsRecordDao.SaveTlsEvaluatorResults(mxRecordTlsProfile, EvaluatorResults.GetHostNotFoundResults(mxRecordTlsProfile.MxHostname))); } _log.Debug($"Evaluating TLS connection results for {mxRecordTlsProfile.MxHostname}."); return(_tlsRecordDao.SaveTlsEvaluatorResults(mxRecordTlsProfile, _mxSecurityEvaluator.Evaluate(mxRecordTlsProfile.ConnectionResults))); }