-
-
Notifications
You must be signed in to change notification settings - Fork 376
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make ValidateCertificateChain/Async() private for now
These might be valuable to make public at some point, but when we do, we might want to provide more info as to why they did not validate. Unfortunately, BouncyCastle does not make that easy to programatically determine via their APIs, so maybe we'd have to live with exceptions. Either way, true/false might not be ideal for a public API. Unit Test changes are all code formatting/style related changes.
- Loading branch information
Showing
5 changed files
with
44 additions
and
65 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
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
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 |
---|---|---|
|
@@ -80,7 +80,8 @@ public abstract class SecureMimeTestsBase | |
public const string ThunderbirdName = "[email protected]"; | ||
|
||
public static readonly string[] RelativeConfigFilePaths = { | ||
"certificate-authority.cfg", "intermediate1.cfg", "intermediate2.cfg", "dnsnames/smime.cfg", "dsa/smime.cfg", "ec/smime.cfg", "nochain/smime.cfg", "revoked/smime.cfg", "revokednochain/smime.cfg", "rsa/smime.cfg" | ||
"certificate-authority.cfg", "intermediate1.cfg", "intermediate2.cfg", "dnsnames/smime.cfg", "dsa/smime.cfg", | ||
"ec/smime.cfg", "nochain/smime.cfg", "revoked/smime.cfg", "revokednochain/smime.cfg", "rsa/smime.cfg" | ||
}; | ||
|
||
public static readonly string[] StartComCertificates = { | ||
|
@@ -2993,7 +2994,6 @@ protected async Task VerifyRevokedCertificateAsync (BouncyCastleSecureMimeContex | |
AssertCrlsRequested (mockHttpMessageHandler); | ||
else | ||
AssertCrlsNotRequested (mockHttpMessageHandler); | ||
|
||
|
||
Assert.That (multipart.Count, Is.EqualTo (2), "The multipart/signed has an unexpected number of children."); | ||
|
||
|
@@ -3056,11 +3056,10 @@ protected async Task VerifyRevokedCertificateAsync (BouncyCastleSecureMimeContex | |
} | ||
} | ||
|
||
protected void VerifyCrlsResolvedWithBuildCertificateChain (BouncyCastleSecureMimeContext ctx, | ||
Mock<HttpMessageHandler> mockHttpMessageHandler) | ||
protected void VerifyCrlsResolvedWithBuildCertificateChain (BouncyCastleSecureMimeContext ctx, Mock<HttpMessageHandler> mockHttpMessageHandler) | ||
{ | ||
var body = new TextPart ("plain") { Text = "This is some cleartext that we'll end up signing..." }; | ||
var certificate = SupportedCertificates.Single(c => c.EmailAddress == "[email protected]"); | ||
var certificate = SupportedCertificates.Single (c => c.EmailAddress == "[email protected]"); | ||
|
||
var signer = new CmsSigner (certificate.FileName, "no.secret"); | ||
var multipart = MultipartSigned.Create (ctx, signer, body); | ||
|
@@ -3081,8 +3080,7 @@ protected void VerifyCrlsResolvedWithBuildCertificateChain (BouncyCastleSecureMi | |
AssertValidSignatures (ctx, signatures); | ||
} | ||
|
||
protected void VerifyCrlsResolved (BouncyCastleSecureMimeContext ctx, | ||
Mock<HttpMessageHandler> mockHttpMessageHandler) | ||
protected void VerifyCrlsResolved (BouncyCastleSecureMimeContext ctx, Mock<HttpMessageHandler> mockHttpMessageHandler) | ||
{ | ||
var body = new TextPart ("plain") { Text = "This is some cleartext that we'll end up signing..." }; | ||
var certificate = SupportedCertificates.Single (c => c.EmailAddress == "[email protected]"); | ||
|
@@ -3136,8 +3134,6 @@ protected void VerifyMimeEncapsulatedSigningWithContext (BouncyCastleSecureMimeC | |
Mock<HttpMessageHandler> mockHttpMessageHandler) | ||
{ | ||
var cleartext = new TextPart ("plain") { Text = "This is some text that we'll end up signing..." }; | ||
|
||
|
||
var certificate = SupportedCertificates.Single (c => c.EmailAddress == "[email protected]"); | ||
|
||
var self = new MailboxAddress ("MimeKit UnitTests", certificate.EmailAddress); | ||
|
@@ -3275,10 +3271,9 @@ public void TestVerifyCrlsResolved () | |
[Test] | ||
public void TestMissingRootCrl () | ||
{ | ||
var responses = new HttpResponseMessage[] | ||
{ | ||
new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(CurrentCrls[1].GetEncoded()) }, | ||
new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(CurrentCrls[2].GetEncoded()) } | ||
var responses = new HttpResponseMessage[] { | ||
new HttpResponseMessage (HttpStatusCode.OK) { Content = new ByteArrayContent (CurrentCrls[1].GetEncoded ()) }, | ||
new HttpResponseMessage (HttpStatusCode.OK) { Content = new ByteArrayContent (CurrentCrls[2].GetEncoded ()) } | ||
}; | ||
var crlUrlIndexes = new[] { 1, 2 }; | ||
var errorContent = RootCertificate.SubjectDN.ToString (); | ||
|
@@ -3289,10 +3284,9 @@ public void TestMissingRootCrl () | |
[Test] | ||
public void TestMissingPrimaryIntermediateCrl () | ||
{ | ||
var responses = new HttpResponseMessage[] | ||
{ | ||
new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(CurrentCrls[0].GetEncoded()) }, | ||
new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(CurrentCrls[2].GetEncoded()) } | ||
var responses = new HttpResponseMessage[] { | ||
new HttpResponseMessage (HttpStatusCode.OK) { Content = new ByteArrayContent (CurrentCrls[0].GetEncoded ()) }, | ||
new HttpResponseMessage (HttpStatusCode.OK) { Content = new ByteArrayContent (CurrentCrls[2].GetEncoded ()) } | ||
}; | ||
var crlUrlIndexes = new[] { 0, 2 }; | ||
var errorContent = IntermediateCertificate1.SubjectDN.ToString (); | ||
|
@@ -3303,10 +3297,9 @@ public void TestMissingPrimaryIntermediateCrl () | |
[Test] | ||
public void TestMissingSecondaryIntermediateCrl () | ||
{ | ||
var responses = new HttpResponseMessage[] | ||
{ | ||
new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(CurrentCrls[0].GetEncoded()) }, | ||
new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(CurrentCrls[1].GetEncoded()) } | ||
var responses = new HttpResponseMessage[] { | ||
new HttpResponseMessage (HttpStatusCode.OK) { Content = new ByteArrayContent (CurrentCrls[0].GetEncoded ()) }, | ||
new HttpResponseMessage (HttpStatusCode.OK) { Content = new ByteArrayContent (CurrentCrls[1].GetEncoded ()) } | ||
}; | ||
var crlUrlIndexes = new[] { 0, 1 }; | ||
var errorContent = IntermediateCertificate2.SubjectDN.ToString (); | ||
|
@@ -3365,7 +3358,7 @@ public MySecureMimeContext (string database, string password, Mock<HttpMessageHa | |
{ | ||
CheckCertificateRevocation = false; | ||
|
||
MockHttpMessageHandler = mockHttpMessageHandler?? CreateMockHttpMessageHandler (RevokedCertificateResponses ()); | ||
MockHttpMessageHandler = mockHttpMessageHandler ?? CreateMockHttpMessageHandler (RevokedCertificateResponses ()); | ||
client = new HttpClient (MockHttpMessageHandler.Object); | ||
} | ||
|
||
|
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