SOLVED: Sitecore Habitat Home Sync-Unicorn fails with the error: GetResponse" with "0" argument(s): "The remote server returned an error: (403) Forbidden.
When executing .\build.ps1 or .\build.ps1 -Target "Post-Deploy" commands to deploy Habitat Home build, the PS script fails with the error message; "GetResponse" with "0" argument(s): "The remote server returned an error: (403) Forbidden."
========================================
Sync-Unicorn
========================================
Sync Unicorn items from url: https://sitecore93sc.dev.local//unicorn.aspx
Executing: &"C:/Code/HabitatHome/scripts/Unicorn/Sync.ps1" -secret 749CABBC85EAD20CE55E2C6066F1BE375D2115696C8A8B24DB6ED1FD60613086 -url https://sitecore93sc.dev.local//unicorn.aspx
Sync-Unicorn: Executing Sync...
An error occurred when executing task 'Sync-Unicorn'.
Error: One or more errors occurred.
Exception calling "GetResponse" with "0" argument(s): "The remote server returned an error: (403) Forbidden."
The key to solving the issue lies in the following lines of code in Unicorn.psm1:
# GET AN AUTH CHALLENGE
$challenge = Get-Challenge -ControlPanelUrl $ControlPanelUrl
if($DebugSecurity) {
Write-Host "Sync-Unicorn: Received challenge from remote server: $challenge"
}
# CREATE A SIGNATURE WITH THE SHARED SECRET AND CHALLENGE
$signatureService = New-Object MicroCHAP.SignatureService -ArgumentList $SharedSecret
$signature = $signatureService.CreateSignature($challenge, $url, $null)
if($DebugSecurity) {
Write-Host "Sync-Unicorn: MAC '$($signature.SignatureSource)'"
Write-Host "Sync-Unicorn: HMAC '$($signature.SignatureHash)'"
Write-Host "Sync-Unicorn: If you get authorization failures compare the values above to the Sitecore logs."
}
Here the options for fixing the issue:
- Ensure the location of MicroCHAP.dll located at scripts\Unicorn in Habitat source code matches what's in the Sitecore's bin.
- Ensure scripts\Unicorn\Unicorn.psm1 file matches your Habitat version.
- Ensure the value of MAC Sitecore gives you matches the value your PowerShell script generated. To debug these values add -DebugSecurity switch in Sync.ps1. This should show an output as follows that will allow you compare the MAC values:
You can find my fix for this issue at https://sitecore.stackexchange.com/questions/10829/exception-when-running-step-05-sync-unicorn-in-habitat-hmac-provided-by-client/25617#25617
Credit to Mark Cassidy's answer in the stackexchange post that provided the background.
Comments
Post a Comment