Skip to content

IISWebAppManagementOnMachineGroupV0 can't detect existing SSL bindings on Server 2022 #1008

@altwohill

Description

@altwohill

I have the following in my yaml pipeline:

  - task: IISWebAppManagementOnMachineGroup@0
    displayName: 'Deploy base website with binding: ${{ binding }}'
    inputs:
      IISDeploymentType: 'IISWebsite'
      ActionIISWebsite: 'CreateOrUpdateWebsite'
#... snipped 
      AddBinding: true
      Protocol: 'https'
      IPAddress: '*'
      Port: 443
      ServerNameIndication: true
      HostNameWithSNI: '${{ binding }}'

It works the first time but fails on repeat deployments on Server 2022 machines.

The issue doesn't occur on our Server 2019 and older machines.

I think the issue is due to some additional lines in the netsh output
image

Looking at

$isItSameBinding = $result.Get(4).Contains([string]::Format("{0}:{1}", $hostname, $port))
and
$isItSameCert = $result.Get(5).ToLower().Contains($certhash.ToLower())
I see the script is checking specific line numbers before proceeding.

On Server 2022 the checks always fail so it tries to add a new binding, which fails with the error

SSL Certificate add failed, Error: 183
Cannot create a file when that file already exists.


##[error]Process 'netsh' exited with code '1'.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions