Skip to content

Commit

Permalink
More certs test MutualTLS
Browse files Browse the repository at this point in the history
  • Loading branch information
thohng committed Nov 18, 2024
1 parent 00cff22 commit 69ffb19
Showing 1 changed file with 39 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,49 @@ namespace NetLah.Extensions.Configuration.Test;
public class CertificateLoaderMutualTlsTest
{
[Theory]
[InlineData("development.dummy_ecdh_p384-2021June.pfx")]
// [InlineData("development.dummy_ecdh_p521-2021June.pfx")]
[InlineData("development.dummy-rsa-2071June.pfx")]
[InlineData("development.dummy-rsa4096-2071June.pfx")]
public void Pkcs12AuthenticationTest(string filename)
[InlineData("development.dummy_ecdh_p384-2021June.pfx", false, true)]
[InlineData("development.dummy_ecdh_p384-2021June_nopass.pfx", false, false)]
#if NET5_0_OR_GREATER
[InlineData("development.dummy_ecdh_p521-2021June.pfx", false, true)]
[InlineData("development.dummy_ecdh_p521-2021June_nopass.pfx", false, false)]
#endif
[InlineData("development.dummy_ecdsa_p384-2024Nov_3ds-sha1.pfx", false, true)]
[InlineData("development.dummy_ecdsa_p384-2024Nov.pfx", false, true)]
[InlineData("development.dummy_ecdsa_p384-2024Nov_nopass.pfx", false, false)]
#if NET5_0_OR_GREATER
[InlineData("development.dummy_ecdsa_p521-2024Nov.pfx", false, true)]
[InlineData("development.dummy_ecdsa_p521-2024Nov_nopass.pfx", false, false)]
#endif
[InlineData("development.dummy-rsa-2071June.pfx", false, true)]
[InlineData("development.dummy-rsa-2071June_nopass.pfx", false, false)]
[InlineData("development.dummy-rsa4096-2071June.pfx", false, true)]
[InlineData("development.dummy-rsa4096-2071June_nopass.pfx", false, false)]
#if NET6_0_OR_GREATER
[InlineData("development.dummy_ecdh_p384-2021June.pem", true, true)]
[InlineData("development.dummy_ecdh_p384-2021June_noenc.pem", true, false)]
[InlineData("development.dummy_ecdh_p521-2021June.pem", true, true)]
[InlineData("development.dummy_ecdh_p521-2021June_noenc.pem", true, false)]
[InlineData("development.dummy_ecdsa_p384-2024Nov.pem", true, true)]
[InlineData("development.dummy_ecdsa_p384-2024Nov_noenc.pem", true, false)]
[InlineData("development.dummy_ecdsa_p521-2024Nov.pem", true, true)]
[InlineData("development.dummy_ecdsa_p521-2024Nov_noenc.pem", true, false)]
[InlineData("development.dummy-rsa-2071June.pem", true, true)]
[InlineData("development.dummy-rsa-2071June_noenc.pem", true, false)]
[InlineData("development.dummy-rsa4096-2071June.pem", true, true)]
[InlineData("development.dummy-rsa4096-2071June_noenc.pem", true, false)]
#endif
public void Pkcs12AuthenticationTest(string filename, bool isPem, bool requirePass)
{
// Cannot use empty password on MacOS with netcoreapp3.1 and before, only supported custom loader since net5.0
// https://github.com/dotnet/runtime/issues/23635#issuecomment-334028941
var filePath = Path.GetFullPath(Path.Combine("Properties", filename));
var certificateConfig = new CertificateConfig { Path = filePath, Password = filename };
var certificateConfig = new CertificateConfig
{
Path = filePath,
KeyPath = isPem ? filePath : null,
IsPem = isPem,
Password = requirePass ? filename : null,
};
var result = CertificateLoader.LoadCertificate(certificateConfig, "Test", requiredPrivateKey: true);

Assert.NotNull(result);
Expand Down

0 comments on commit 69ffb19

Please sign in to comment.