Make X509CertificatePassword optional (#732)

This commit is contained in:
Stef Heyenrath
2022-03-01 19:46:33 +01:00
committed by GitHub
parent 6c68033739
commit a9e8e01877
3 changed files with 10 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using System.Security.Cryptography.X509Certificates;
@@ -57,7 +57,12 @@ namespace WireMock.HttpsCertificate
return new X509Certificate2(filePath, password);
}
throw new InvalidOperationException("X509StoreName and X509StoreLocation OR X509CertificateFilePath and X509CertificatePassword are mandatory.");
if (!string.IsNullOrEmpty(filePath))
{
return new X509Certificate2(filePath);
}
throw new InvalidOperationException("X509StoreName and X509StoreLocation OR X509CertificateFilePath are mandatory. Note that X509CertificatePassword is optional.");
}
/// <summary>

View File

@@ -80,7 +80,7 @@ namespace WireMock.Owin
/// <inheritdoc cref="IWireMockMiddlewareOptions.CustomCertificateDefined"/>
public bool CustomCertificateDefined =>
!string.IsNullOrEmpty(X509StoreName) && !string.IsNullOrEmpty(X509StoreLocation) ||
!string.IsNullOrEmpty(X509CertificateFilePath) && !string.IsNullOrEmpty(X509CertificatePassword);
!string.IsNullOrEmpty(X509CertificateFilePath);
/// <inheritdoc cref="IWireMockMiddlewareOptions.SaveUnmatchedRequests"/>
public bool? SaveUnmatchedRequests { get; set; }

View File

@@ -1,4 +1,4 @@
using JetBrains.Annotations;
using JetBrains.Annotations;
namespace WireMock.Settings
{
@@ -31,6 +31,6 @@ namespace WireMock.Settings
[PublicAPI]
public bool IsDefined =>
!string.IsNullOrEmpty(X509StoreName) && !string.IsNullOrEmpty(X509StoreLocation) ||
!string.IsNullOrEmpty(X509CertificateFilePath) && !string.IsNullOrEmpty(X509CertificatePassword);
!string.IsNullOrEmpty(X509CertificateFilePath);
}
}