Add option to disable certificate revocation check when sending email.

This commit is contained in:
Jared Goodwin 2021-04-20 11:43:48 -07:00
parent 9fda52a22b
commit 1cbc6648dd
6 changed files with 25 additions and 5 deletions

View File

@ -28,25 +28,26 @@ namespace Remotely.Server.Pages
return Page();
}
public async Task<IActionResult> OnPost(string deviceID)
public async Task<IActionResult> OnPost(string deviceId)
{
if (!ModelState.IsValid)
{
return Page();
}
var orgID = _dataService.GetDevice(deviceID)?.OrganizationID;
var orgID = _dataService.GetDevice(deviceId)?.OrganizationID;
var alertParts = new string[]
{
$"{Input.Name} is requesting support.",
$"Device ID: {deviceId}",
$"Email: {Input.Email}.",
$"Phone: {Input.Phone}.",
$"Chat OK: {Input.ChatResponseOk}."
};
var alertMessage = string.Join(" ", alertParts);
await _dataService.AddAlert(deviceID, orgID, alertMessage);
await _dataService.AddAlert(deviceId, orgID, alertMessage);
var orgUsers = await _dataService.GetAllUsersInOrganization(orgID);
var emailMessage = string.Join("<br />", alertParts);
@ -57,7 +58,7 @@ namespace Remotely.Server.Pages
StatusMessage = "We got it! Someone will contact you soon.";
return RedirectToPage("GetSupport", new { deviceID });
return RedirectToPage("GetSupport", new { deviceId });
}
public class InputModel

View File

@ -250,6 +250,16 @@
<br />
<ValidationMessage For="() => Input.SmtpPort" />
</div>
<div class="form-group">
<label class="control-label">SMTP Check Certificate Revocation</label>
<div class="small text-muted">
This sometimes needs to be disabled for Let's Encrypt certificates.
</div>
<br />
<InputCheckbox @bind-Value="Input.SmtpCheckCertificateRevocation" autocomplete="off" />
<br />
<ValidationMessage For="() => Input.SmtpCheckCertificateRevocation" />
</div>
<div class="form-group">
<label class="control-label">SMTP Local Domain</label>
<br />

View File

@ -84,6 +84,9 @@ namespace Remotely.Server.Pages
[Display(Name = "SMTP Local Domain")]
public string SmtpLocalDomain { get; set; }
[Display(Name = "SMTP Check Certificate Revocation")]
public bool SmtpCheckCertificateRevocation { get; set; }
[Display(Name = "SMTP Password")]
public string SmtpPassword { get; set; }
@ -320,7 +323,7 @@ namespace Remotely.Server.Pages
}
else
{
ToastService.ShowToast("Error sending email. Check the server logs for details.");
ToastService.ShowToast("Error sending email. Check the server logs for details.", classString: "bg-error");
_alertMessage = "Error sending email. Check the server logs for details.";
}
}

View File

@ -30,6 +30,7 @@ namespace Remotely.Server.Services
string SmtpPassword { get; }
int SmtpPort { get; }
string SmtpUserName { get; }
bool SmtpCheckCertificateRevocation { get; }
Theme Theme { get; }
string[] TrustedCorsOrigins { get; }
bool UseHsts { get; }
@ -72,6 +73,7 @@ namespace Remotely.Server.Services
public string SmtpPassword => Config["ApplicationOptions:SmtpPassword"];
public int SmtpPort => int.Parse(Config["ApplicationOptions:SmtpPort"] ?? "25");
public string SmtpUserName => Config["ApplicationOptions:SmtpUserName"];
public bool SmtpCheckCertificateRevocation => bool.Parse(Config["ApplicationOptions:SmtpCheckCertificateRevocation"] ?? "true");
public Theme Theme => Enum.Parse<Theme>(Config["ApplicationOptions:Theme"] ?? "Dark", true);
public string[] TrustedCorsOrigins => Config.GetSection("ApplicationOptions:TrustedCorsOrigins").Get<string[]>() ?? System.Array.Empty<string>();
public bool UseHsts => bool.Parse(Config["ApplicationOptions:UseHsts"] ?? "false");

View File

@ -46,6 +46,9 @@ namespace Remotely.Server.Services
{
client.LocalDomain = AppConfig.SmtpLocalDomain;
}
client.CheckCertificateRevocation = AppConfig.SmtpCheckCertificateRevocation;
await client.ConnectAsync(AppConfig.SmtpHost, AppConfig.SmtpPort);
await client.AuthenticateAsync(AppConfig.SmtpUserName, AppConfig.SmtpPassword);

View File

@ -45,6 +45,7 @@
"SmtpPassword": "",
"SmtpPort": 587,
"SmtpUserName": "",
"SmtpCheckCertificateRevocation": true,
"Theme": "Dark",
"TrustedCorsOrigins": [],
"UseHsts": false,