microsoft / navcontainerhelper

Official Microsoft repository for BcContainerHelper, a PowerShell module, which makes it easier to work with Business Central Containers on Docker.
MIT License
383 stars 246 forks source link

Publish-NavContainerApp: Exception setting "ServerCertificateCustomValidationCallback": "Cannot convert the "static bool DisabledServerCertificateValidationCallback #3116

Closed hhoutaptean closed 1 year ago

hhoutaptean commented 1 year ago

Issue When deploying environments (using https://bcinsider.azureedge.net/sandbox/22.4.58605.0/base) on basis of the navarmtemplate and publishing extensions we got the below error when using BcContainerHelper v5.0.4 when using the Publish-NavContainerApp command with -useDevEndpoint, to work around we switched back to BcContainerHelper v5.0.3:

ForEach-Object : Exception setting "ServerCertificateCustomValidationCallback": "Cannot convert the "static bool DisabledServerCertificateValidationCallback(System.Object sender, X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)" value of type "System.Management.Automation.PSMethod" to type "System.Func`5[System.Net.Http.HttpRequestMessage,Sys tem.Security.Cryptography.X509Certificates.X509Certificate2,System.Security.Cryptography.X509Certificates.X509Chain,System.Net.Security.SslPolicyErrors,System.Boolean]". " At C:\Program Files\WindowsPowerShell\Modules\bccontainerhelper\5.0.4\AppHandling\Publish-NavContainerApp.ps1:157 char:43 '+ $appFiles | Where-Object { $_ } | ForEach-Object { '+ ~~~~ ' + CategoryInfo : NotSpecified: (:) [ForEach-Object], SetValueInvocationException ' + FullyQualifiedErrorId : ExceptionWhenSetting,Microsoft.PowerShell.Commands.ForEachObjectCommand

Scripts used to create container

https://github.com/microsoft/nav-arm-templates

Full output of scripts

5:01:48 PM Finished FinalSetupScript
5:01:48 PM Removing license files(s) (.flf and .bclicense).
5:01:48 PM Setting Docker Engine service startup type to: delayed-auto.
5:01:47 PM Failed to publish, sync or install apps.
4:57:10 PM Installing apps from folder: C:\ProgramData\BcContainerHelper\apps.
4:55:26 PM Downloading apps to folder: C:\ProgramData\BcContainerHelper\apps.
4:55:26 PM Setting PasswordNeverExpires for user: vmadmin.
4:55:18 PM Invoking Company Initialize and UserExperience to Premium (codeunit2 and 9178) in company: ApteanFandB.
4:54:57 PM Creating new company: ApteanFandB in container: bcserver.
4:54:57 PM Creating SUPER user: user manager\containeradministrator.
4:54:48 PM Creating users.
4:50:12 PM Disabling Windows Defender realtime monitoring.
4:50:11 PM Disabling Windows Defender scheduled tasks.
4:50:10 PM Running FinalSetupScript
4:50:10 PM Desktop setup complete!
4:50:09 PM Creating Desktop Shortcuts
4:49:52 PM Installing .vsix
4:49:50 PM Downloading samples
4:49:28 PM Installing Visual Studio Code (this might take a few minutes)
4:49:27 PM Setting up Desktop Experience
4:49:27 PM Container setup complete!
4:49:27 PM Ready for connections!
4:49:27 PM Initialization took 19 seconds
4:49:27 PM Container Free Physical Memory is 11.6Gb
4:49:27 PM Container Total Physical Memory is 16.0Gb
4:49:27 PM http://...:8080/ALLanguage.vsix
4:49:27 PM Files:
4:49:27 PM Setting bcserver to ... in host hosts file
4:49:27 PM Dev. ServerInstance : BC
4:49:27 PM Dev. Server : https://....com
4:49:27 PM Web Client : https://.../
4:49:27 PM Container Dns Name : ...
4:49:27 PM Container Hostname : bcserver
4:49:27 PM Container IP Address: ...
4:49:27 PM Starting Service Tier
4:49:27 PM Starting Internet Information Server
4:49:27 PM Starting Local SQL Server
4:49:27 PM Using AccessControlService Authentication
4:49:27 PM PublicDnsName is ...
4:49:27 PM Hostname is bcserver
4:49:27 PM PublicDnsName unchanged
4:49:27 PM Restarting Container
4:49:27 PM Setting host.containerhelper.internal to ... in container hosts file
4:49:27 PM Initializing...
4:49:27 PM Ready for connections!
4:49:27 PM Initialization took 60 seconds
4:49:27 PM Container Free Physical Memory is 11.3Gb
4:49:27 PM Container Total Physical Memory is 16.0Gb
4:49:27 PM http://...:8080/ALLanguage.vsix
4:49:27 PM Files:
4:49:27 PM Setting bcserver to ... in host hosts file
4:49:27 PM Dev. ServerInstance : BC
4:49:27 PM Dev. Server : https://....com
4:49:27 PM Web Client : https://.../BC/
4:49:27 PM Container Dns Name : ....com
4:49:27 PM Container Hostname : bcserver
4:49:27 PM Container IP Address: ...
4:49:27 PM Assign Premium plan for VMADMIN
4:49:26 PM Creating SUPER user
4:49:26 PM Creating vmadmin as SQL User and add to sysadmin
4:49:26 PM Setting SA Password and enabling SA
4:49:26 PM Creating http download site
4:49:26 PM Import License
4:49:26 PM Using license file 'c:\run\my\license.bclicense'
4:49:26 PM Enabling Financials User Experience
4:49:26 PM Setting AadAuthorityUri to https://...
4:49:26 PM Setting AadApplicationId to ...
4:49:26 PM Modifying Web Client config with settings from environment variable
4:49:26 PM Done Configuring Web Client
4:49:26 PM Update configuration: navsettings.json
4:49:26 PM Create website: NavWebApplicationContainer with SSL
4:49:26 PM Create the application pool BC
4:49:26 PM Copy files to WWW root C:\inetpub\wwwroot\BC
4:49:26 PM Using default container name: NavWebApplicationContainer
4:49:26 PM Using application pool name: BC
4:49:26 PM Creating DotNetCore Web Server Instance
4:49:26 PM Registering event sources
4:49:26 PM CertificateThumprint ...
4:49:26 PM Starting Service Tier
4:49:26 PM Setting ClientServicesCredentialType to NavUserPassword
4:49:26 PM Setting ExtendedSecurityTokenLifetime to 24
4:49:26 PM Setting DisableTokenSigningCertificateValidation to True
4:49:26 PM Setting ValidAudiences to ....com
4:49:26 PM Setting EnableTaskScheduler to true
4:49:26 PM Modifying Service Tier Config File with settings from environment variable
4:49:26 PM Modifying Service Tier Config File with Instance Specific Settings
4:49:26 PM Import Certificate to LocalMachine\my
4:49:26 PM Certificate File Thumbprint ...
4:49:26 PM Starting Internet Information Server
4:49:26 PM Starting Local SQL Server
4:49:26 PM Using AccessControlService Authentication
4:49:26 PM PublicDnsName is ....com
4:49:26 PM Hostname is bcserver
4:49:26 PM Starting Container
4:49:26 PM Setting host.containerhelper.internal to ... in container hosts file
4:49:26 PM Initializing...
4:49:26 PM Container output
4:49:26 PM Copying .vsix and Certificate to C:\ProgramData\bccontainerhelper\Extensions\bcserver
4:35:45 PM Running container (this might take some time)
4:35:45 PM Locale en-US
4:35:45 PM Version 22.4.58605.0
4:35:45 PM Country w1
4:35:45 PM Using artifactUrl https://bcinsider.azureedge.net/sandbox/22.4.58605.0/base
4:34:58 PM Creating Aad Apps for Office 365 integration
4:32:23 PM Installing OpenXML 2.5
4:32:20 PM Installing SQL Native Client
4:32:12 PM Installing Visual C++ Redist
4:32:12 PM mcr.microsoft.com/businesscentral:10.0.20348.1787
4:32:12 PM Status: Downloaded newer image for mcr.microsoft.com/businesscentral:10.0.20348.1787
4:32:12 PM Digest: sha256:fdeb77c50df5aff1323243915ee9c36854bc51ed9bdfa6cde587c69066eecdac
4:32:12 PM 71f47f8ad1f8: Pull complete
4:32:10 PM fe285fe5c150: Pull complete
4:32:09 PM 30fbb7116100: Pull complete
4:32:08 PM dd575eb97d82: Pull complete
4:32:07 PM 2b9309eb6c07: Pull complete
4:31:13 PM 2759c72264c4: Pull complete
4:31:12 PM be5e5d858d8c: Pull complete
4:29:55 PM f9ee43d4d3b5: Pull complete
4:29:54 PM 301f6940435a: Pull complete
4:29:53 PM 47214f2ac238: Pull complete
4:29:53 PM f38df5000877: Pull complete
4:29:52 PM a7617db3795a: Pull complete
4:29:41 PM 54fb39347095: Pull complete
4:29:39 PM 7c76e5cf7755: Pull complete
4:26:47 PM 7c76e5cf7755: Download complete
4:26:47 PM 7c76e5cf7755: Verifying Checksum
4:26:43 PM 2b9309eb6c07: Download complete
4:26:40 PM 71f47f8ad1f8: Download complete
4:26:40 PM 71f47f8ad1f8: Verifying Checksum
4:26:40 PM fe285fe5c150: Download complete
4:26:40 PM fe285fe5c150: Verifying Checksum
4:26:40 PM 30fbb7116100: Download complete
4:26:40 PM 30fbb7116100: Verifying Checksum
4:26:40 PM dd575eb97d82: Download complete
4:26:40 PM dd575eb97d82: Verifying Checksum
4:26:40 PM be5e5d858d8c: Download complete
4:26:40 PM be5e5d858d8c: Verifying Checksum
4:26:35 PM 2759c72264c4: Download complete
4:26:35 PM 2759c72264c4: Verifying Checksum
4:26:34 PM a7617db3795a: Download complete
4:26:34 PM a7617db3795a: Verifying Checksum
4:26:34 PM f9ee43d4d3b5: Download complete
4:26:34 PM f9ee43d4d3b5: Verifying Checksum
4:26:34 PM 301f6940435a: Download complete
4:26:34 PM 301f6940435a: Verifying Checksum
4:26:34 PM 47214f2ac238: Download complete
4:26:34 PM 47214f2ac238: Verifying Checksum
4:26:34 PM f38df5000877: Download complete
4:26:34 PM f38df5000877: Verifying Checksum
4:26:34 PM 54fb39347095: Download complete
4:26:34 PM 54fb39347095: Verifying Checksum
4:26:34 PM 71f47f8ad1f8: Waiting
4:26:34 PM fe285fe5c150: Waiting
4:26:34 PM 30fbb7116100: Waiting
4:26:34 PM dd575eb97d82: Waiting
4:26:34 PM 2b9309eb6c07: Waiting
4:26:34 PM 2759c72264c4: Waiting
4:26:34 PM be5e5d858d8c: Waiting
4:26:34 PM f9ee43d4d3b5: Waiting
4:26:34 PM 301f6940435a: Waiting
4:26:34 PM 47214f2ac238: Waiting
4:26:34 PM f38df5000877: Waiting
4:26:34 PM 71f47f8ad1f8: Pulling fs layer
4:26:34 PM fe285fe5c150: Pulling fs layer
4:26:34 PM 30fbb7116100: Pulling fs layer
4:26:34 PM dd575eb97d82: Pulling fs layer
4:26:34 PM 2b9309eb6c07: Pulling fs layer
4:26:34 PM 2759c72264c4: Pulling fs layer
4:26:34 PM be5e5d858d8c: Pulling fs layer
4:26:34 PM f9ee43d4d3b5: Pulling fs layer
4:26:34 PM 301f6940435a: Pulling fs layer
4:26:34 PM 47214f2ac238: Pulling fs layer
4:26:33 PM f38df5000877: Pulling fs layer
4:26:33 PM a7617db3795a: Pulling fs layer
4:26:33 PM 54fb39347095: Pulling fs layer
4:26:33 PM 7c76e5cf7755: Pulling fs layer
4:26:33 PM 10.0.20348.1787: Pulling from businesscentral
4:26:32 PM Pulling mcr.microsoft.com/businesscentral:10.0.20348.1787 (this might take some time)
4:26:30 PM Adding Landing Page to Startup Group
4:26:30 PM Add Import bccontainerhelper to PowerShell profile
4:26:30 PM Disabling Server Manager Open At Logon
4:26:30 PM Show hidden files and file types
4:26:30 PM Enabling Font Download in IE
4:26:30 PM Enabling File Download in IE
4:26:30 PM Starting docker
4:26:12 PM Using Lets Encrypt certificate
4:25:43 PM Installing ACME-PS PowerShell Module
4:25:30 PM SetupVm, User: vmadmin
4:25:22 PM Launch SetupVm
4:25:20 PM Register RestartContainers Task to start container delayed
4:23:00 PM Installing SqlServer module
4:13:53 PM Installing Microsoft.Graph module
4:13:33 PM Installing AzureAD module
4:07:28 PM Installing Az module
4:07:28 PM Using BcContainerHelper version 5.0.4
4:06:47 PM Installing Latest Business Central Container Helper from PowerShell Gallery
4:06:45 PM SetupStart, User: ...$
4:04:24 PM Restarting computer and start Installation tasks
4:03:13 PM Downloading C:\DEMO\InstallOrUpdateDockerEngine.ps1
4:03:13 PM Downloading c:\demo\FinalSetupScript.ps1
4:03:13 PM Downloading C:\DEMO\Install-VS2017Community.ps1
4:03:13 PM Downloading c:\demo\restartContainers.ps1
4:03:12 PM Downloading c:\demo\SetupStart.ps1
4:03:12 PM Downloading c:\demo\SetupVm.ps1
4:03:12 PM Downloading c:\demo\SetupNavContainer.ps1
4:03:12 PM Downloading c:\demo\SetupDesktop.ps1
4:03:11 PM Downloading c:\myfolder\SetupWebClient.ps1
4:03:11 PM Turning off IE Enhanced Security Configuration
4:03:11 PM Creating Connect.rdp
4:03:11 PM Downloading C:\inetpub\wwwroot\web.config
4:03:11 PM Downloading C:\inetpub\wwwroot\Microsoft.png
4:03:11 PM Downloading C:\inetpub\wwwroot\line.png
4:03:10 PM Downloading C:\inetpub\wwwroot\status.aspx
4:03:10 PM Downloading C:\inetpub\wwwroot\default.aspx
4:01:01 PM Installing Internet Information Server (this might take a few minutes)
4:00:28 PM Installing PowerShellGet 2.2.5
4:00:26 PM Installing NuGet Package Provider
4:00:08 PM TemplateLink: https://...getbcext.json
4:00:08 PM Initialize, user: ...$
4:00:08 PM Running Windows Server 2022 Datacenter
4:00:08 PM Starting initialization
freddydk commented 1 year ago

The place where you got the error:

ForEach-Object : Exception setting "ServerCertificateCustomValidationCallback": "Cannot convert the "static bool
DisabledServerCertificateValidationCallback(System.Object sender, X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain,
System.Net.Security.SslPolicyErrors sslPolicyErrors)" value of type "System.Management.Automation.PSMethod" to type "System.Func`5[System.Net.Http.HttpRequestMessage,Sys
tem.Security.Cryptography.X509Certificates.X509Certificate2,System.Security.Cryptography.X509Certificates.X509Chain,System.Net.Security.SslPolicyErrors,System.Boolean]".
"
At C:\Program Files\WindowsPowerShell\Modules\bccontainerhelper\5.0.4\AppHandling\Publish-NavContainerApp.ps1:157 char:43
'+ $appFiles | Where-Object { $_ } | ForEach-Object {
'+ ~~~~~~~~~~~~~~~~
' + CategoryInfo : NotSpecified: (:) [ForEach-Object], SetValueInvocationException
' + FullyQualifiedErrorId : ExceptionWhenSetting,Microsoft.PowerShell.Commands.ForEachObjectCommand

could you share some more output before the error? Are you running PowerShell 7 or PS 5? Does it say: Downloading using WebClient or Downloading using HttpClient?

freddydk commented 1 year ago

No need to reply - I can see the reason why this is failing...

freddydk commented 1 year ago

Shipped