Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Publishing from Visual Studio 2015 - allow untrusted certificates

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:

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.

There is no option to allow untrusted certificates in publishing settings.

like image 792
koryakinp Avatar asked Nov 11 '15 20:11

koryakinp


People also ask

How do I enable untrusted certificate?

Navigate to the site with the cert you want to trust, and click through the usual warnings for untrusted certificates. In the address bar, right click on the red warning triangle and "Not secure" message and, from the resulting menu, select "Certificate" to show the certificate.

How do I enable untrusted certificate in Visual Studio 2019?

In Visual Studio 2019, we don't have the UI to trust the certificate. To allow self signed cert, you can add the following property to the csproj or the pubxml under Properties\Publish Profiles. pubxml. Thank you for your feedback!

How do I trust a certificate in Visual Studio?

On the File menu, click Add/Remove Snap-in. In the Add or Remove Snap-ins dialog box, select Certificates, and then click Add. In the Certificates snap-in dialog box, select Computer account, and then click Next. In the Select Computer dialog box, select Local Computer, and then click Finish.

How do I publish a Visual Studio 2015 profile?

Create a publish profile in Visual Studio by choosing one of the following paths: Right-click the project in Solution Explorer and select Publish. Select Publish {PROJECT NAME} from the Build menu.


2 Answers

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.

  1. Open the publish profile file (.pubxml) inside /Properties/PublishProfiles in a text editor
  2. Inside the <PropertyGroup> element, set AllowUntrustedCertificate to True (<AllowUntrustedCertificate>True</AllowUntrustedCertificate>) or add it if it doesn't exist
  3. Set UsePowerShell to False (<UsePowerShell>False</UsePowerShell>).

At this time of writing, the generated powershell script disregards the AllowUntrustedCertificate property which is probably a bug, hence, the need to set it to False.

You can get powershell to work if you update the module version in the .ps1 file.

As a side note, you can also get around this problem by "trusting" the server's certificate locally.

like image 69
Dealdiane Avatar answered Sep 30 '22 22:09

Dealdiane


For dot net core 1.0 you have to add the tag

 <AllowUntrustedCertificate>True</AllowUntrustedCertificate> 

to publishprofiles in your .pubxml file

like image 26
pedrommuller Avatar answered Sep 30 '22 22:09

pedrommuller