Getting "Could not create SSL/TLS secure channel." on Windows Server 2012 R2 - webclient

The following code runs just fine on my development workstation (Windows 10 Pro), running in Visual Studio. As you can probably guess from the naming convention, I am using WebClient to post to a remote https:// endpoint.
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
resp = m_WebClient.UploadValues(m_WebClient.BaseAddress, "POST", postParams);
However, when I deploy it to my production server (Windows Server 2012 R2 Datacenter - it's an Azure VM), I am trapping the following exception:
The request was aborted: Could not create SSL/TLS secure channel.
at System.Net.WebClient.UploadValues(Uri address, String method, NameValueCollection data)
at System.Net.WebClient.UploadValues(String address, String method, NameValueCollection data)
at rater8.ReviewShake.Request.Processor.TryGetRESTApi(Int32 CompanyId, String ScrapeString, String LastJobId, String& Response)
I know that I am capable of communicating from my production server to the remote server because I've executed the call in Postman from the production server. I receive a 200 - OK. I know the remote server insists on TLS1.2, because if I disable that protocol in Postman, the call fails.
This is production code which has been running until just a couple of days ago. I will contact the vendor, but support can be spotty. In the meantime, does anyone have any ideas? Is there something which I need to configure at the OS level in order to enable this on Windows Server 2012? (I do have Windows Update running.) Thanks!
Since posting, I've accumulated two additional facts:
Switching over to HttpWebRequest did not have any positive effect.
Moving the executable over to another Windows 10 Pro machine did have a positive effect, the connection was successfully established.
So the critical combination of factors here which cause this to break is the combination of Windows Server 2012 R2 and my C# code (WebClient or HttpWebRequest). Recall that Postman was able to establish communication from the Windows Server so that, in and of itself is not the issue. Must be some esoteric handshake issue, but I'm running out of ideas. Thanks for any advice which you can provide!

Currently dealing with the same thing. We were running a web api call on a 2012 R2 server, it was working but all of a sudden, it stopped working around the time of your post.
I would assume that this is a bug with Microsoft, however here are the current solutions that I am testing that make sense.
Try another server install version, we noticed it was working with a 2016 server
I've noticed that this issue generally came to fruition when microsoft released a new VS 2019 Update, maybe try another editor or downgrade your vs2019 ide?
Maybe try downgrading your .NET framework version to something a bit more stable.
These are things I am currently testing, but the most definite one that is working is getting an install of 2016 server or 2019. Spinning up a new server install for short term period until the issue is fixed, might just be up your alley.
Edit:
At this time, the move to a updated server seems to have fixed the issue.

Related

Web Deploy not working. Timeout on client. Schannel 1203 on server

I'm trying to deploy an application via web deploy to a windows 2012 r2 server.
First tried installing iis, web deploy using the msi. After getting an unreachable error I saw somewhere that I needed wmsvc to be installed and installed it via powershell command Install-WindowsFeature Web-Mgmt-Service.
I stopped getting the unreachable error and started getting this error ->
Error: Could not complete the request to remote agent URL 'http://xx.x.xx.xx:8172/MSDEPLOYAGENTSERVICE'.
Error: The operation has timed out
On the server's event viewer under system I get the following error ->
A fatal alert was generated and sent to the remote endpoint. This may result in termination of the connection. The TLS protocol defined fatal error code is 10. The Windows SChannel error state is 1203.
Any idea of what could be going on? Did I miss something on the installation?
After this I also tried installing everything but without iis and I get the same error.
So, this is really not a PoSH issue.
Maybe you should consider movin gthis question to another forum.
Anyway, you have either real server config issues (this can sometimes mean wipe and rebuild - very ugly option - but if it's a virtual machine and you have a snapshot, just roll back), or an app causing this.
Typically for Schannel type of error, it has to do with application or service in machine not able to complete any SSL connection sort of connection.
The error state parameter of 1203 means client error connecting to server, ie invalid ClientHello from the client
See if you can collect more data by...
https://support.microsoft.com/en-us/help/260729/how-to-enable-schannel-event-logging-in-iis
I realized this is an old question, but in case somebody ran into the same issue, here are my solution.
I had to follow this guidelines : https://learn.microsoft.com/en-us/aspnet/web-forms/overview/deployment/configuring-server-environments-for-web-deployment/configuring-a-web-server-for-web-deploy-publishing-web-deploy-handler
Copy the resulting publishsetting file. In the Publish/Profile page import it.
In the Publish/Connection page, change the server to the server address with the 8172 port. Add the password. Change the Destination URL to the site to go to after the publish is completed.
Then after Validate connection was completed, go ahead and publish it!

VS 2013 Web Deployment Failing - Socket Error 10054

I posted on friday regarding this issue and received no response, however since then some updates have occurred which might affect whether people have an answer to my question or not.
I'm trying to deploy an MVC website to Azure, and in this particular project the web deploy receives a Socket Error 10054 and gives up after 10 attempts saying it was Unable to write data to the transport connection. It makes varying progress in between the socket failures but never completes within the 10 attempts.
I have since had a play around with other projects which are deployed to different url locations within this same Azure Account and they deploy fine! I think this means the problem is not on my end, i.e. port 8172 is open and deployment can be achieved with my current local settings.
What are the problems that can cause this socket error 10054? I saw somewhere that I should enable the "Allow untrusted certificate" option when deploying but I can't find that option within VS 2013.
Any ideas are welcome please,
This issue is driving me mad, it seems there's a real mixed bag of solution ideas which have worked for others but not me.
JK

Access denied on MessageQueue.GetPrivateQueuesByMachine

I'm trying to get the list of available queues on the remote machine. The machine is a Win2003R2 in Workgroup mode, and the client machine that runs the code is a Windows 8 machine both using the same Workgroup name. I get an exception when running the following code:
var messages = MessageQueue.GetPrivateQueuesByMachine("Win2003SRV");
And the error message is:
base {System.Runtime.InteropServices.ExternalException}: {"Access to Message Queuing system is denied."}
Message: "Access to Message Queuing system is denied."
MessageQueueErrorCode: AccessDenied
I'm pretty sure it has something to do with permissions on Windows 2003 but couldn't find much. The code works fine with another Win Server 2008 (but in workgroup mode) and works with local MSMQ as well. According to the MSDN page, this function is supported on Workgroup mode, so what's the catch?
SOLVED:
My issue turned out to be that I didn't have MSMQ installed on my Client machine! The help on the link pointed me to the right direction, so all I had to do was to install MSMQ on client machine as well. If you look at the implementation of GetPrivateQueuesByMachine, the native call can throw a DllNotFoundException and it is that exception that translates into that specific message, so it should give you a hint on what is wrong
John Breakwell who is/was a msmq MVP has a few posts which may help. The problem seems to be caused because the GetPrivateQueuesByMachine() method uses RPC under the hood to communicate between queue managers on different machines.
http://blogs.msdn.com/b/johnbreakwell/archive/2010/03/24/understanding-how-msmq-security-blocks-rpc-traffic.aspx

Finding out what went wrong with the Windows 2008 R2 Production server

This morning my Production server (Windows 2008 R2) went offline for 10 mins and also RDP connection was lost for the given duration. During this period the IIS 7 hosted production web site also stopped responding.
Luckily though, after the 10 mins the server was up by its own and RDP session was restored to previous state.
Now the question is how do I find out what went wrong in the server and is there any logs which I can go through verify my findings.
If you goto the run prompt and type eventvwr it will open Event Viewer. From within here expand the Windows Logs tree and look through the System logs. Something will have caused the reboot and you should be able to find it through here.
A good old chesnut is Windows Updates. They aren't on auto install and reboot are they? :]

transport-level error has occurred when receiving results from the server(provider:TCP Provider, error: 0-The semaphore timeout period has expired)

We have an application server with the following spec’s:
• Windows 2008 R2 operating system.
• All prerequisites are configures successfully and correctly: Windows roles, MSDTC and connection to SQL DB server.
• MS Reporting Services 2008 R2 are installed and configured successfully, and all reports are deployed and render with no problems.
The application server connects to SQL Server 2008 R2 DB on different server - there are no firewalls between the 2 servers , and using UDL file, the connection is always successful using windows authentication or SQL authentication on SQL Server.
When we install “K2 blackpearl 4.5 (4.10060.1.0) with Update KB001040”, the setup completes successfully but the following exception appears when we open work list, when K2 setup manager is opened for reconfiguration and when rendering any report on the report manager: “A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - The semaphore timeout period has expired.)” although all DB’s are created successfully during the installation for K2. Also all other features at K2 (any feature at Management Console) and Report Manager (deployment of reports, management of data sources, and folder/report settings) works perfectly.
When we remove K2 components from the server the reporting services works successfully again, without any reconfiguration.
We tried to move the server to new environment to check if there is a problem with the server itself, all installation and configuration are completed with no problems and the error message disappeared.
We did check all of below points:
• MSDTC configuration.
• All ports are open between the 2 servers.
• SQL connection is always successful between the 2 servers.
• We have a third server with MOSS 2007 installed and it works perfectly with problems in connection to DB.
• All users used for windows services and SQL windows connection are active and configured correctly.
o Have SQL login with dbcreator and SecurityAdmin roles.
o Are added as Administrators on Application server.
• We have tries Windows authentication and SQL authentication and they all gave the same problem.
• We have used a newer version of K2 installation files “K2 blackpearl 4.5 (4.10060.1.0) with KB001320” and it failed at the last steps of installation with the same problem.
Please help on this.
(full disclosure i work for K2) and looked through our system as well as the support forum and could not find a reference to this error. From the people i talked to it appears to be a general network issue, with quite a few possible causes, including something as simple as the network card. Although I am not 100% clear on a few points you made. When you said
"following exception appears when we open work list" Where are you opening the worklist from?
When you said
"When we remove K2 components from the server the reporting services works successfully again, without any reconfiguration."
Are you getting this error in SQL Reporting Services?
You can also post a question in http://k2underground.com someone else may have seen this.
Edit I asked around and there does not seem to be any good answers to this at the moment. Would you be willing to open a K2 support ticket and let us look at the K2 logs or see the config via livemeeting? Thanks!