.net 从 Visual Studio 2015 发布 - 允许不受信任的证书
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33659696/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Publishing from Visual Studio 2015 - allow untrusted certificates
提问by koryakinp
I am publishing my ASP.NET 5 MVC6 project from Visual Studio 2015. I have imported publish profile from my server. Connection validates successfully, however when I publish my project I have the following error:
我正在从 Visual Studio 2015 发布我的 ASP.NET 5 MVC6 项目。我已经从我的服务器导入了发布配置文件。连接验证成功,但是当我发布我的项目时出现以下错误:
ERROR_CERTIFICATE_VALIDATION_FAILED
ERROR_CERTIFICATE_VALIDATION_FAILED
Connected to the remote computer ("XXXXXXXXX") using the specified process ("Web Management Service"), but could not verify the server's certificate. If you trust the server, connect again and allow untrusted certificates.
使用指定的进程(“Web 管理服务”)连接到远程计算机(“XXXXXXXXX”),但无法验证服务器的证书。如果您信任服务器,请再次连接并允许不受信任的证书。
There is no option to allow untrusted certificates in publishing settings.
在发布设置中没有允许不受信任的证书的选项。
回答by Dealdiane
The option to allow untrusted certificates is not yet supported in the current tooling. Hopefully, this gets updated very soon. You can, however, set it manually.
当前工具尚不支持允许不受信任证书的选项。希望这会很快更新。但是,您可以手动设置它。
- Open the publish profile file (
.pubxml) inside /Properties/PublishProfiles in a text editor - Inside the
<PropertyGroup>element, set AllowUntrustedCertificate to True (<AllowUntrustedCertificate>True</AllowUntrustedCertificate>) or add it if it doesn't exist - Set UsePowerShell to False (
<UsePowerShell>False</UsePowerShell>).
.pubxml在文本编辑器中打开/Properties/PublishProfiles 中的发布配置文件 ( )- 在
<PropertyGroup>元素内部,将 AllowUntrustedCertificate 设置为 True (<AllowUntrustedCertificate>True</AllowUntrustedCertificate>) 或者如果它不存在则添加它 - 将 UsePowerShell 设置为 False (
<UsePowerShell>False</UsePowerShell>)。
At this time of writing, the generated powershell script disregards the AllowUntrustedCertificateproperty which is probably a bug, hence, the need to set it to False.
在撰写本文时,生成的 powershell 脚本忽略了AllowUntrustedCertificate可能是错误的属性,因此需要将其设置为False.
You can get powershell to work if you update the module versionin the .ps1file.
如果您更新.ps1文件中的模块版本,您可以使 powershell 工作。
As a side note, you can also get around this problem by "trusting" the server's certificate locally.
作为旁注,您还可以通过在本地“信任”服务器的证书来解决此问题。
回答by Hyman.the.ripper
For dot net core 1.0 you have to add the tag
对于 dot net core 1.0,您必须添加标签
<AllowUntrustedCertificate>True</AllowUntrustedCertificate>
to publishprofiles in your .pubxml file
在 .pubxml 文件中发布配置文件
回答by spottedmahn
I had <UsePowerShell>True</UsePowerShell>but it was still failing with the cert error.
我有,<UsePowerShell>True</UsePowerShell>但它仍然因证书错误而失败。
- I re-entered my password in the settings dialog and it still failed
- Once I clicked on Validate Connectionit started working.
- 我在设置对话框中重新输入了密码,但仍然失败
- 单击“验证连接”后,它开始工作。
Note
笔记
- VS 2017 (15.2)
- My password recently changed
- As a test, entered the wrongpassword and I got the cert error so the cert error is not just about an untrusted cert apparently
- VS 2017 (15.2)
- 我最近更改了密码
- 作为测试,输入了错误的密码,我得到了证书错误,因此证书错误显然不仅仅是一个不受信任的证书
回答by paqogomez
For me, the solution took 4 lines in the publish profile xml.
对我来说,该解决方案在发布配置文件 xml 中占用了 4 行。
<AllowUntrustedCertificate>True</AllowUntrustedCertificate>
<UseMsDeployExe>true</UseMsDeployExe>
<UserName>myuser</UserName>
<Password>mypass</Password>
The UseMsDeployExechanges the error to ignore the certificate, but not authenticate the user, hence the need for the user and pass (of the machine you're deploying to)
在UseMsDeployExe改变了错误忽略证书,但无法验证用户,因此需要用户,并通过(机器要部署到)
No changes were needed in the powershell script.
powershell 脚本中不需要任何更改。
回答by Daniel Adigun
Update
更新
Just a little observation, when deploying a .net core app on VS2015 or VS2017 community, to a remote IIS server please use this
稍微观察一下,在 VS2015 或 VS2017 社区上部署 .net core app 到远程 IIS 服务器时请使用这个
<UsePowerShell>True</UsePowerShell>
not
不是
<UsePowerShell>False</UsePowerShell>
Discovered that deployment was completing as successful but no files were copied to server until I changed the tag to true.
发现部署成功完成但没有文件被复制到服务器,直到我将标签更改为true。
I hope this helps someone.
我希望这可以帮助别人。
回答by Kenan Begi?
After importing or creating profile click configure and then validate connection. Enter password and finish the setup. Now deploy.
导入或创建配置文件后,单击配置,然后验证连接。输入密码并完成设置。现在部署。
回答by nraduka
回答by ArieKanarie
Yet another solution
另一个解决方案
I created publish settings on the remote IIS and imported them in Visual Studio 2017 (15.2). After that I changed the URL to specify the sitename as the IIS-user only has access to the specific site (thanks to thisanswer on SO). I've entered the credentials via the UI and there is no need to store the password in the profile.
我在远程 IIS 上创建了发布设置并将它们导入到 Visual Studio 2017 (15.2) 中。之后,我更改了 URL 以指定站点名称,因为 IIS 用户只能访问特定站点(感谢SO上的这个答案)。我已通过 UI 输入凭据,无需在配置文件中存储密码。
My profile looks like:
我的个人资料看起来像:
<WebPublishMethod>MSDeploy</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish>https://some.site.com:443/</SiteUrlToLaunchAfterPublish>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<PublishFramework>netcoreapp1.1</PublishFramework>
<ProjectGuid>eecf975e-f2e6-440f-bfd6-a0a63c25e3c3</ProjectGuid>
<MSDeployServiceURL>https://url.toourserver.com:8172/msdeploy.axd?site=some.site.com</MSDeployServiceURL>
<DeployIisAppPath>some.site.com</DeployIisAppPath>
<RemoteSitePhysicalPath />
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<EnableMSDeployBackup>True</EnableMSDeployBackup>
<UserName>IISUserName</UserName>
<AllowUntrustedCertificate>True</AllowUntrustedCertificate>
<_SavePWD>True</_SavePWD>
<AllowUntrustedCertificate>was needed as the self signed certificate is not trusted on my machine.
<AllowUntrustedCertificate>需要,因为我的机器上不信任自签名证书。
With this profile a backup is made according to the settings in IIS, the site is updated and opened in my browser when the process is finished :-)
使用此配置文件根据 IIS 中的设置进行备份,该过程完成后,站点会更新并在我的浏览器中打开 :-)
Although all the other answers here also made it work, I thought it would be nice to share this way as it involves only a few changes (AllowUntrustedCertificate) and no storage of plain passwords.
尽管这里的所有其他答案也使它起作用,但我认为以这种方式分享会很好,因为它只涉及一些更改(AllowUntrustedCertificate)并且不存储普通密码。


