Posts

Showing posts from May, 2021

Using the .NET WCF BasicHttpBinding to access a web service using both Client Certificates AND Windows Authentication.

If you're using the WCF BasicHttpBinding to access a web service you may wish to connect using Windows Authentication over HTTPS but also present a client certificate to add an extra layer of security (two factor authentication). The problem is whilst you can add a client certificate it is ignored because settings the ClientCredentialType to Windows means that only Windows authentication is used. BasicHttpBinding basicBinding = new BasicHttpBinding(BasicHttpSecurityMode.Transport); basicBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows; SchedulerAccessWebServiceSoapClient server = new SchedulerAccessWebServiceSoapClient(binding, remoteAddress); server.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.LocalMachine, StoreName.My, X509FindType.FindByThumbprint, " be4bca8c388af02ee1c50c3f5f74d6a34fe97daf " ); When you try and access the web service when Require Client Certificates is enabled you see an error similar to this. S...

VMware workstation listening on port 443

Image
When using VMware workstation you may find that VMware workstation is listening on port 443. Running netstat -anb shows the following TCP    0.0.0.0:443            0.0.0.0:0              LISTENING [vmware-hostd.exe] To change this in VMware workstation go to Edit > Preferences > Shared VMs (deprecated) and you can stop sharing here, or disable the port.

Determine which process is using a specific port using PowerShell.

Image
If you find that a process is using a TCP port and you want to know which process is using that port it's easy with PowerShell using the Get-NetTCPConnection and Get-Process cmdlets. # Determine which process is using port 443 $owningProcess = (Get-NetTCPConnection -State Listen -LocalPort 443|SELECT OwningProcess)[0]; $processName = Get-Process -Id $owningProcess.OwningProcess|SELECT ProcessName; Write-Host "Port 443: $($processName.ProcessName)";

The Add Service Reference context menu is missing from Visual Studio and refreshing a service reference displays the error "The current project does not support service references. To enable Windows Communication Foundation support, change the target version of the Microsoft .NET Framework"

Image
 In Visual Studio you notice that the "Add Service Reference" context menu is missing. Refreshing an existing service reference shows the following error "The current project does not support service references. To enable Windows Communication Foundation support, change the target version of the Microsoft .NET  Framework" The solution to this was due to the solution .sln file. Rename the solution file, create a new blank solution and re-add the project. Rebuild and then the system works.