Octopus v2018.7.8. - PathTooLongException - LoadCertificateFromFile

Hello,

we recently updated to v2018.7.8 and started getting a following exception when deploying to Azure WebApps (even for the release packages which worked before):

System.IO.PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters. 
    August 9th 2018 11:14:50Error
       at System.IO.LongPathHelper.Normalize(String path, UInt32 maxPathLength, Boolean checkInvalidCharacters, Boolean expandShortPaths) 
    August 9th 2018 11:14:50Error
       at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths) 
    August 9th 2018 11:14:50Error
       at System.IO.Path.GetFullPathInternal(String path) 
    August 9th 2018 11:14:50Error
       at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String fileName, Object password, X509KeyStorageFlags keyStorageFlags) 
    August 9th 2018 11:14:50Error
       at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName) 
    August 9th 2018 11:14:50Error
       at Calamari.Azure.Integration.Websites.Publishing.ServiceManagementPublishProfileProvider.GetPublishProperties(AzureAccount account, AzureTargetSite targetSite) 
    August 9th 2018 11:14:50Error
       at Calamari.Azure.Deployment.Conventions.AzureWebAppConvention.GetPublishProfile(VariableDictionary variables) 
    August 9th 2018 11:14:50Error
       at Calamari.Azure.Deployment.Conventions.AzureWebAppConvention.Install(RunningDeployment deployment) 
    August 9th 2018 11:14:50Error
       at Calamari.Deployment.ConventionProcessor.RunInstallConventions() 
    August 9th 2018 11:14:50Error
       at Calamari.Deployment.ConventionProcessor.RunConventions() 
    August 9th 2018 11:14:50Error
    Running rollback conventions... 
    August 9th 2018 11:14:50Error
    The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters. 
    August 9th 2018 11:14:50Error
    System.IO.PathTooLongException 
    August 9th 2018 11:14:50Error
       at System.IO.LongPathHelper.Normalize(String path, UInt32 maxPathLength, Boolean checkInvalidCharacters, Boolean expandShortPaths) 
    August 9th 2018 11:14:50Error
       at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths) 
    August 9th 2018 11:14:50Error
       at System.IO.Path.GetFullPathInternal(String path) 
    August 9th 2018 11:14:50Error
       at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String fileName, Object password, X509KeyStorageFlags keyStorageFlags) 
    August 9th 2018 11:14:50Error
       at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName) 
    August 9th 2018 11:14:50Error
       at Calamari.Azure.Integration.Websites.Publishing.ServiceManagementPublishProfileProvider.GetPublishProperties(AzureAccount account, AzureTargetSite targetSite) 
    August 9th 2018 11:14:50Error
       at Calamari.Azure.Deployment.Conventions.AzureWebAppConvention.GetPublishProfile(VariableDictionary variables) 
    August 9th 2018 11:14:50Error
       at Calamari.Azure.Deployment.Conventions.AzureWebAppConvention.Install(RunningDeployment deployment) 
    August 9th 2018 11:14:50Error
       at Calamari.Deployment.ConventionProcessor.RunInstallConventions() 
    August 9th 2018 11:14:50Error
       at Calamari.Deployment.ConventionProcessor.RunConventions() 
    August 9th 2018 11:14:50Error
       at Calamari.Azure.Commands.DeployAzureWebCommand.Execute(String[] commandLineArguments) 
    August 9th 2018 11:14:50Error
       at Calamari.Program.Execute(String[] args) 
    August 9th 2018 11:14:54Fatal
    The remote script failed with exit code 100 

A step before this one we are actually starting a WebApp deployment slot using the Azure Powershell script and the log output is following:

Adding certificate '' into Cert:\CurrentUser\My  (marked exportable) 
August 9th 2018 11:12:22Info
Imported certificate 'CN=Octopus Deploy - Online-Test' into store 'My' 
August 9th 2018 11:12:22Info
Located certificate 'CN=Octopus Deploy - Online-Test' in Cert:\CurrentUser\My 
August 9th 2018 11:12:28Info

(Upgraded Octopus is generating here a bit different output than we got before the upgrade.)

I am not aware of any certificate changes on our side. What would be the best solution/workaround here?

Best Regards,
Jindrich

Hi Jindrich,

Thanks for getting in touch and sorry you’ve hit this bug with the Web App deployments. We’ve done some analysis on this and found the issue, which only surfaces when you use Management Certificates for an Azure Web App deployment.

We’ve created a GitHub issue that you can track. We have a patch on the way, which shouldn’t be too far away.

Another alternative you do have is to move to using a Service Principal, which is also the recommended approach from Microsoft now as they are deprecating the APIs that use the Management Certificates.

Hope that helps and apologies for the inconvenience.

Regards
Shannon

Use Long Path Tool, Long Path Tool can simplify and probably end your problems in unlocking, managing and renaming files that appear to have a long filename

1 Like