WebAdministrationDsc icon indicating copy to clipboard operation
WebAdministrationDsc copied to clipboard

xWebsite binding failing in pull mode

Open subbunori opened this issue 9 years ago • 8 comments

Hi, I am using xWebsite with Azure Automation DSC to setup a server and I see the below error.

"ErrorRecord": "Failure to add certificate to web binding. Please make sure that the certificate thumbprint "" is valid. Error: "Value does not fall within the expected range.".",

It works fine if I use it in push mode though. Am I missing anything?

xWebSite WebSite
            {
                Ensure = "Present"
                Name = "TestDSC"
                ApplicationPool = "TestDSC"
                PhysicalPath = "D:\Inetpub"
                BindingInfo = @(
                                    MSFT_xWebBindingInformation
                                    {
                                        Protocol              = "HTTPS"
                                        Port                  = "9443"
                                        CertificateThumbprint = "‎‎<my cert thumbprint here>"
                                    }
                                )
            }

When I used dsc debug, I found that it is throwing error exactly at $binding.addsslcertificate call below.

image

subbunori avatar Dec 15 '16 08:12 subbunori

Pretty sure you need to include the Certificate Store Name? At least in the version I am using. BindingInfo = @( MSFT_xWebBindingInformation { Protocol = "HTTPS" Port = 8443 CertificateThumbprint = "71AD93562316F21F74606F1096B85D66289ED60F" CertificateStoreName = "WebHosting" },

JonosGit avatar Dec 16 '16 18:12 JonosGit

@JonosGit Thanks for responding. MY is a default value as mentioned in Convert-To-WebBinding method. I do have my cert in MY. And yes, I did try explicitly mentioning MY but it is the same error.

 if ([String]::IsNullOrEmpty($binding.CertificateStoreName))
                    {
                        $certificateStoreName = 'MY'
                        Write-Verbose -Message `
                            ($LocalizedData.VerboseConvertToWebBindingDefaultCertificateStoreName `
                            -f $certificateStoreName)
                    }

subbunori avatar Dec 16 '16 19:12 subbunori

Any help here? I used debugging to narrow down to exactly which statement is giving this error. The thumbprint is fine and when I take this statement and run it myself, it works fine. It only fails when running in pull mode (with Azure Automation DSC). It runs under system account with both push and pull mode, so what are some other differences I need to know here?

Function : Update-WebsiteBinding Statement : $methodInstance.Execute()

stack trace is

writeErrorStream : True Exception : System.Management.Automation.MethodInvocationException: Exception calling "Execute" with "0" argument(s): "Value does not fall within the expected range." ---> System.ArgumentException: Value does not fall within the expected range. at Microsoft.IIs.PowerShell.Framework.Interop.IAppHostMethodInstance.Execute() at CallSite.Target(Closure , CallSite , Object ) --- End of inner exception stack trace --- at System.Management.Automation.ExceptionHandlingOps.ConvertToMethodInvocationException(Exception exception, Type typeToThrow, String methodName, Int32 numArgs, MemberInfo memberInfo) at CallSite.Target(Closure , CallSite , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0) at System.Management.Automation.Interpreter.DynamicInstruction`2.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) TargetObject : CategoryInfo : NotSpecified: (:) [], MethodInvocationException FullyQualifiedErrorId : ArgumentException ErrorDetails : InvocationInfo : System.Management.Automation.InvocationInfo ScriptStackTrace : at Update-WebsiteBinding, C:\Program Files\WindowsPowerShell\Modules\xWebAdministration\1.15.0.0 \DscResources\MSFT_xWebsite\MSFT_xWebsite.psm1: line 2074 at Set-TargetResource, C:\Program Files\WindowsPowerShell\Modules\xWebAdministration\1.15.0.0\Ds cResources\MSFT_xWebsite\MSFT_xWebsite.psm1: line 284 PipelineIterationInfo : {} PSMessageDetails :

subbunori avatar Jan 12 '17 04:01 subbunori

@subbunori I will investigate this and get back to you

nzspambot avatar Jan 25 '17 03:01 nzspambot

@subbunori did you get an answer to this issue?

johlju avatar Apr 26 '18 12:04 johlju

No

On Thu, Apr 26, 2018, 5:48 AM Johan Ljunggren [email protected] wrote:

@subbunori https://github.com/subbunori did you get an answer to this issue?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PowerShell/xWebAdministration/issues/269#issuecomment-384628797, or mute the thread https://github.com/notifications/unsubscribe-auth/AXOyxr5vAjOg5uB9-MMzlQ41HJ5dM6rVks5tscIUgaJpZM4LN0Y8 .

subbunori avatar Apr 26 '18 14:04 subbunori

@subbunori Thanks for answering after such a long time! Do you still have this problem or did you find a solution by yourself?

johlju avatar Apr 26 '18 14:04 johlju