WCF + web api + No connection could be made because the target machine actively refused it x.x.x.x:443 - wcf

I am accessing a third party web api from my WCF application. While development I was able to access those APIs but when I deployed my WCF to IIS, its not able to connect to the web API and throwing me the following error:
"System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it X.X.X.X:443"
Just to make sure that my server is fine where I deployed my WCF. I tried accessing those web api from a simple console application. It accessed those apis from my development machine and from the server machine as well. Now I feel the culprit is not the third party web api server, but something goes wrong when a WCF service access' a web-api hosted in IIS.
Please help!!!

Finally I found the issue. IIS runs my WCF under user 'network service' or 'application pool identity'. These are nothing but window built-in users which has limited access. When I tried accessing third party API from the console application it worked because it was running under my user credential which has admin credential. So I concluded that when an application making cross-domain call then it should be running under a user with enough credential to make such calls.
Solution was to change my application pool identity to a admin user identity (I changed it to my logged in user). It worked and making calls to third party API from WCF service

Related

HTTP Error 503. The service is unavailable - Application pools stopped my API service Url in my aws remote server

In my AWS remote Desktop, I have hosted my web application and API service application using IIS(internet information service). In that, Application pools stopped my API service in remote desktop IIS at every midnight of lesser usage time. In the morning always I restart my API services in IIS then it works fine. I need a permanent solution to fix this problem always API service will be in Up. Please suggest your solution.Attachment for reference

How to Consume Non-public NTLM WCF Service From Windows Azure Cloud Service?

I have a Windows Azure Cloud Service with a single worker role. The worker role's App.config file specifies NTLM credentials should be used for the WCF authentication (Gist for all of this : http://goo.gl/wFCLv7 ).
Everything works as expected locally but when I deploy my CloudService to Azure, though I am prompted to enter my NTLM credentials (which are successfully audited according to the Windows Event Security logs of the Worker Role's machine which I RDP onto), invocations of the WCF service return null. (I don't know how to gather further debugging information)
After verifying with colleagues, sure enough the host machine for the WCF service is private, and not publicly facing - this probably explains why I can't query it from my application when it is hosted on the cloud, even with my Windows Authentication credentials.
How to I leverage non-public, NTLM-secure WCF services from Windows Azure? What do I need to change on the WCF server in order to consume the services from Azure? An easy answer may be to make the WCF host public - however the company is very fearful of "The Cloud" as it is -- is there a smaller alternative that can used for proof of concept?
Best,
networking/security/Azure noob

Authentication against Active Directory using a Mobile Device

I currently have a Mobile Application that communicates through a WCF Service to access a Database. The Mobile App can access on the network as well as externally. It connects to the WCF Service which is hosted on one server inside the network. From there the WCF Service is pointing at another server which is hosting the Database that the Mobile Device is accessing.
With the above process how would you setup authentication using Active Directory which would confirm the user of the Mobile Application before it can access the WCF Service to confirm that the user is a member of AD and they can then login after authorization is complete. This would occur as the user opens up the Application. Would this be coded into the App to prompt for the information, then send the information to the WCF Service which would then allow access? If not this then are there any other ways or information/links that can be provided please?
Take a look at the BUILD 2013 videos. Visual Studio 2013 will create a webproject that will automagically do all that for you (I think). Just bare in mind, it uses the Microsoft.OWin.Security beta packages.
Also...you will need to install the AspNetWebTools2013 package first...
http://www.asp.net/visual-studio/overview/2013/creating-web-projects-in-visual-studio#orgauthoptions

How can I simultaneously authenticate to an IIS7-hosted javascript web client and WCF service using Windows Authentication?

I have created and tested a WCF REST service that is protected with SSL and Windows Authentication through IIS 7. I have also created and tested a pure html/javascript web client that is hosted in IIS 7 that is protected with SSL and Windows Authentication -- same server, different "site" within IIS. The REST service is not public, but the web client is.
Without security, everything works beautifully, but now we are ready for field testing and security must be implemented.
My end goal is to have the user visit mywebclient.com and authenticate using their Active Directory accounts. Initially I thought it would be safe to leave the service calls from the client to the REST service unprotected (since the traffic from the web client to the web service would be internal), but this does not protect us from an internal attacker. Also, in the future, the REST services will be available to handhelds through native applications.
I've tried to gain as much information on this subject as possible, but every piece of Microsoft documentation contains client examples written in .NET.
How can I share the security context between these sites without converting the web client to a .NET-based application? Could this be accomplished by combining the web client and service into one IIS "site"?
Edit: If the client and service exist in the same app pool, does that mean they could share authentication information between client and server processes?

Web Services only connecting to Trusted Devices

I am on a project that uses web services to communicate with hand held devices (Symbol MC70s running windows mobile 5).
We need to make sure that others on the internet can't connect to the web services and start sending info.
I have made a certificate so that the hand held will only connect to my services, but I don't know how to make sure that my services will only connect to my hand held devices.
My app is coded in the .NET Compact Framework and I am using Visual Studio 2008 SP1. My services are hosted in IIS and are coded with WCF in C# (.NET 3.5 sp1).
Any ideas?
Password-protect the services. Alternatively, authenticate the client by the client SSL certificate and issue those to your users.
No way to lock access down to a specific device. A device can be spoofed fairly easily.
When you say that you've "... made a certificate so that the hand held will only connect to my services", are you saying that the device uses https to the web service or that the device is locked down to only connect to the web service http URL?
Anyway, if you are concerned about the data pulled from the web service, you could encrypt it with a key known to your device.