Error System.ArgumentNullException: Value cannot be null when deploying working script to a target on new build server

Hi,
I created new octopus deployment on another server version 2019.12.0 , I copied currently working process over to the new server and getting this error:
Executing feature-class ‘Calamari.Deployment.Features.IisWebSiteBeforeDeployFeature’
System.ArgumentNullException: Value cannot be null.
Parameter name: findValue
at System.Security.Cryptography.X509Certificates.X509Certificate2Collection.FindCertInStore(SafeCertStoreHandle safeSourceStoreHandle, X509FindType findType, Object findValue, Boolean validOnly)
at System.Security.Cryptography.X509Certificates.X509Certificate2Collection.Find(X509FindType findType, Object findValue, Boolean validOnly)
at Calamari.Deployment.Features.IisWebSiteBeforeDeployFeature.FindCertificateInLocalMachineStore(String thumbprint)
at Calamari.Deployment.Features.IisWebSiteBeforeDeployFeature.EnsureCertificateInStore(VariableDictionary variables, String certificateVariable)
at Calamari.Deployment.Features.IisWebSiteBeforeDeployFeature.EnsureCertificatesUsedInBindingsAreInStore(VariableDictionary variables)
at Calamari.Deployment.Features.IisWebSiteBeforeDeployFeature.Execute(RunningDeployment deployment)
at Calamari.Deployment.Conventions.FeatureConventionBase.ExecuteFeatureClasses(RunningDeployment deployment, String feature)
at Calamari.Deployment.Conventions.FeatureConventionBase.Run(RunningDeployment deployment)
at Calamari.Deployment.ConventionProcessor.RunInstallConventions()
at Calamari.Deployment.ConventionProcessor.RunConventions()

How do I fix this?

Hi @mamacdonald,

Thanks for reaching out, and sorry to hear you are having trouble with your newly imported deployment process, but I would be happy to help take a closer look.

Upon initial review of the information you attached, it looks like the process is erroring in finding the certificate to use for this deployment:

System.ArgumentNullException: Value cannot be null.
Parameter name: findValue
at System.Security.Cryptography.X509Certificates.X509Certificate2Collection.FindCertInStore(SafeCertStoreHandle safeSourceStoreHandle, X509FindType findType, Object findValue, Boolean validOnly)
at System.Security.Cryptography.X509Certificates.X509Certificate2Collection.Find(X509FindType findType, Object findValue, Boolean validOnly)
at Calamari.Deployment.Features.IisWebSiteBeforeDeployFeature.FindCertificateInLocalMachineStore(String thumbprint)
at Calamari.Deployment.Features.IisWebSiteBeforeDeployFeature.EnsureCertificateInStore(VariableDictionary variables, String certificateVariable)

In setting up your process, if you are using our Deploy to IIS step template, you can specify the certificate to be used within the Bindings section of the deployment process:

This can either be a certificate managed by Octopus Deploy (in which case you would need to ensure that there is a valid project variable associated with the certificate being used in the process), or you can reference a certificate in the local certificate store on the deployment target.

I recommend reviewing this section in your process, and if nothing sticks out as an issue here, you could try enabling variable debugging for your project, which will let you inspect all the passed-in/evaluated variables in your deployment process via the task log. Once you’ve enabled these special variables for debugging, you’ll need to create and deploy a fresh release in order for these to be also picked up in the process.

Hopefully these two avenues of investigation help shed some light on what’s happening, but if not, feel free to upload a sample raw task log for me to review (preferably with variable debugging enabled) at the following secure link, and I would be glad to help further.

Regards,

Britton

Hi Britton,
I just uploaded the raw data with the print variables. It does see the certificate.
Does the website have to be created in IIS before running octopus or will octopus create it?
(My previous site was setup by a former employee)
Thanks,
Mary

Using v2019.12.0 with .net 4.5 application. Trying to deploy to new 2022 web server.

Hi @mamacdonald,

Thanks for uploading the log and also for the updates!

In taking a look, I see that this process is set to merge with any existing IIS bindings; if you want this process to be the source of truth for configuration, then you’d want to set this to Replace existing bindings (default), which will replace any existing bindings (rather than merging with potentially incorrect existing values):

With this in place, Octopus Deploy will push the configuration you’ve set and replace this with any existing bindings on the server.

I also noticed that the #{SiteName} variable doesn’t look to be populated throughout the log, which could also be causing this issue as this is passed into the binding command. I’m not sure if you have this value bound to a custom variable, but it would be under the Web Site section in the Deploy to IIS step template:

I hope this additional information helps, but me know if I can be of any more assistance.

Regards,

Britton

Hi @mamacdonald,

I also wanted to add that the #{SiteName} variable looks like it might be populated within the binding(s) themselves, so it would be good to confirm this section looks as expected (Host name in the bindings configuration pop-up):

image

Sorry for the double post, but I wanted to clarify my initial message.

I hope this helps,

Britton

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.