-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SAN to SS certs that are generated.
- Loading branch information
Showing
3 changed files
with
23 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
using MailKit.Security; | ||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | ||
using MimeKit; | ||
using MimeKit.Cryptography; | ||
using OpenQA.Selenium; | ||
using OpenQA.Selenium.Chrome; | ||
using OpenQA.Selenium.Support.Extensions; | ||
|
@@ -10,6 +11,8 @@ | |
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Net.Security; | ||
using System.Security.Cryptography.X509Certificates; | ||
using System.Threading; | ||
using WebDriverManager; | ||
using WebDriverManager.DriverConfigs.Impl; | ||
|
@@ -35,18 +38,18 @@ public void CheckMessageIsReceivedAndDisplayed(string basePath, bool inMemoryDb) | |
RunUITest($"{nameof(CheckMessageIsReceivedAndDisplayed)}-{basePath}-{inMemoryDb}", (browser, baseUrl, smtpPortNumber) => | ||
{ | ||
browser.Navigate().GoToUrl(baseUrl); | ||
HomePage homePage = new HomePage(browser); | ||
var homePage = new HomePage(browser); | ||
|
||
HomePage.MessageListControl messageList = WaitFor(() => homePage.MessageList); | ||
Assert.NotNull(messageList); | ||
|
||
string messageSubject = Guid.NewGuid().ToString(); | ||
using (SmtpClient smtpClient = new SmtpClient()) | ||
using (var smtpClient = new SmtpClient()) | ||
{ | ||
smtpClient.SslProtocols = System.Security.Authentication.SslProtocols.Tls12; | ||
smtpClient.ServerCertificateValidationCallback = (s, c, h, e) => true; | ||
smtpClient.ServerCertificateValidationCallback = GetCertvalidationCallbackHandler(); | ||
smtpClient.CheckCertificateRevocation = false; | ||
MimeMessage message = new MimeMessage(); | ||
var message = new MimeMessage(); | ||
message.To.Add(MailboxAddress.Parse("[email protected]")); | ||
message.From.Add(MailboxAddress.Parse("[email protected]")); | ||
|
||
|
@@ -62,7 +65,7 @@ public void CheckMessageIsReceivedAndDisplayed(string basePath, bool inMemoryDb) | |
smtpClient.Disconnect(true, new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token); | ||
} | ||
|
||
HomePage.Grid.GridRow messageRow = WaitFor(() => messageList.Grid?.Rows?.SingleOrDefault()); | ||
HomePage.Grid.GridRow messageRow = WaitFor(() => (messageList.Grid?.Rows?.SingleOrDefault())); | ||
Assert.NotNull(messageRow); | ||
|
||
Assert.Contains(messageRow.Cells, c => c.Text.Contains(messageSubject)); | ||
|
@@ -73,6 +76,11 @@ public void CheckMessageIsReceivedAndDisplayed(string basePath, bool inMemoryDb) | |
}); | ||
} | ||
|
||
private static RemoteCertificateValidationCallback GetCertvalidationCallbackHandler() | ||
{ | ||
return (s, c, h, e) => new X509Certificate2(c.GetRawCertData()).GetSubjectDnsNames().Contains("localhost"); | ||
} | ||
|
||
[Fact] | ||
public void CheckUTF8MessageIsReceivedAndDisplayed() | ||
{ | ||
|
@@ -88,7 +96,7 @@ public void CheckUTF8MessageIsReceivedAndDisplayed() | |
using (SmtpClient smtpClient = new SmtpClient() { }) | ||
{ | ||
smtpClient.SslProtocols = System.Security.Authentication.SslProtocols.None; | ||
smtpClient.ServerCertificateValidationCallback = (s, c, h, e) => true; | ||
smtpClient.ServerCertificateValidationCallback = GetCertvalidationCallbackHandler(); | ||
smtpClient.CheckCertificateRevocation = false; | ||
MimeMessage message = new MimeMessage(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters