No password for custom certificate #407

Closed
opened 2025-12-29 15:22:56 +01:00 by adam · 8 comments
Owner

Originally created by @arihantjain0894 on GitHub (Feb 28, 2022).

Hi,
I have a scenario where my custom certificate has no password. I am not able to use it, i guess because of the below code.

public bool IsDefined =>
      !string.IsNullOrEmpty(X509StoreName) && !string.IsNullOrEmpty(X509StoreLocation) ||
      !string.IsNullOrEmpty(X509CertificateFilePath) && !string.IsNullOrEmpty(X509CertificatePassword);

Any suggestion?

Originally created by @arihantjain0894 on GitHub (Feb 28, 2022). Hi, I have a scenario where my custom certificate has no password. I am not able to use it, i guess because of the below code. ``` c# public bool IsDefined => !string.IsNullOrEmpty(X509StoreName) && !string.IsNullOrEmpty(X509StoreLocation) || !string.IsNullOrEmpty(X509CertificateFilePath) && !string.IsNullOrEmpty(X509CertificatePassword); ``` Any suggestion?
adam added the question label 2025-12-29 15:22:56 +01:00
adam closed this issue 2025-12-29 15:22:57 +01:00
Author
Owner

@StefH commented on GitHub (Feb 28, 2022):

Hi @arihantjain0894,

Good point.

I think that a simple solution would be to change it to:

&& X509CertificatePassword != null;

But also I need to add some logic to detect empty pwd.

Which means that if you provide an empty string "" as X509CertificatePassword, this IsDefined will return true.

OR

I could remove the check for X509CertificatePassword here, But also I need to add some logic to detect empty pwd.

@StefH commented on GitHub (Feb 28, 2022): Hi @arihantjain0894, Good point. I think that a simple solution would be to change it to: ``` c# && X509CertificatePassword != null; ``` But also I need to add some logic to detect empty pwd. Which means that if you provide an empty string `""` as X509CertificatePassword, this `IsDefined ` will return `true`. OR I could remove the check for X509CertificatePassword here, But also I need to add some logic to detect empty pwd.
Author
Owner

@StefH commented on GitHub (Feb 28, 2022):

@arihantjain0894
Can you try preview version 1.4.36-ci-15933? (https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions)

@StefH commented on GitHub (Feb 28, 2022): @arihantjain0894 Can you try preview version `1.4.36-ci-15933`? (https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions)
Author
Owner

@StefH commented on GitHub (Feb 28, 2022):

@arihantjain0894
Does the preview version work correct for you?

@StefH commented on GitHub (Feb 28, 2022): @arihantjain0894 Does the preview version work correct for you?
Author
Owner

@arihantjain0894 commented on GitHub (Mar 1, 2022):

@StefH , thanks for the fix. Its working.
Should we remove entire "!string.IsNullOrEmpty(X509CertificatePassword)" or change the X509CertificatePassword != null as suggested earlier?
7f57d0ddbe

@arihantjain0894 commented on GitHub (Mar 1, 2022): @StefH , thanks for the fix. Its working. Should we remove entire "!string.IsNullOrEmpty(X509CertificatePassword)" or change the X509CertificatePassword != null as suggested earlier? https://github.com/WireMock-Net/WireMock.Net/pull/732/commits/7f57d0ddbe0d8aa14cd499092f38dce2bd795f57
Author
Owner

@StefH commented on GitHub (Mar 1, 2022):

The exception will be like:
"X509StoreName and X509StoreLocation OR X509CertificateFilePath are mandatory. Note that X509CertificatePassword is optional.

I think this fine?

@StefH commented on GitHub (Mar 1, 2022): The exception will be like: `"X509StoreName and X509StoreLocation OR X509CertificateFilePath are mandatory. Note that X509CertificatePassword is optional.` I think this fine?
Author
Owner

@arihantjain0894 commented on GitHub (Mar 1, 2022):

My initial thought was to let "X509CertificatePassword" still be mandatory, but including string.Empty as one of the valid password. If we are making Password as optional altogether then we are good.

@arihantjain0894 commented on GitHub (Mar 1, 2022): My initial thought was to let "X509CertificatePassword" still be mandatory, but including string.Empty as one of the valid password. If we are making Password as optional altogether then we are good.
Author
Owner

@StefH commented on GitHub (Mar 1, 2022):

OK

A new version will be released tomorrow.

@StefH commented on GitHub (Mar 1, 2022): OK A new version will be released tomorrow.
Author
Owner

@StefH commented on GitHub (Mar 1, 2022):

https://github.com/WireMock-Net/WireMock.Net/pull/732

@StefH commented on GitHub (Mar 1, 2022): https://github.com/WireMock-Net/WireMock.Net/pull/732
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#407