Showing posts with label security. Show all posts
Showing posts with label security. Show all posts
Friday, November 25, 2016
Solving the dreaded MQ_ERROR_CORRUPTED_SECURITY_DATA (0xC00E0030) MSMQ error
I recently started getting a the error MQ_ERROR_CORRUPTED_SECURITY_DATA (0xC00E0030) when trying to execute tests on my development box while publishing to MSMQ queues. As indicated by the error, the cause was corrupted security data. I had recently changed my development machine from one directory over to another. Going into the MSMQ Server properties in compmgmt.msc (Computer Management) and clearing out all the certifticates for my user, renewing them and reregistering the certificates with Active Directory fixed the issue.
Wednesday, April 08, 2015
Removing a certificate binding from a port in Windows
As many people don't know, in Windows certificates can be bound to ports for securing content transferred over those ports. IIS happens to be particularly negatively affected by this if another program has a certificate bound to a port that you want to use, e.g. 443 for serving web pages.
Use the information at the following page to find the certificate binding and delete it :
https://msdn.microsoft.com/en-us/library/ms733791(v=vs.110).aspx
The short version:
Find the port: netsh http show sslcert | grep -C 5 443
This command will show all the SSL certificates that are bound to ports on your machine.
Delete the port: netsh http delete sslcert ipport=0.0.0.0:443
This should help deal with some of the more annoying (and less verbose) errors when doing things like trying to configure WCF services to use SSL.
Use the information at the following page to find the certificate binding and delete it :
https://msdn.microsoft.com/en-us/library/ms733791(v=vs.110).aspx
The short version:
Find the port: netsh http show sslcert | grep -C 5 443
This command will show all the SSL certificates that are bound to ports on your machine.
Delete the port: netsh http delete sslcert ipport=0.0.0.0:443
This should help deal with some of the more annoying (and less verbose) errors when doing things like trying to configure WCF services to use SSL.
Monday, May 06, 2013
Journey to robust webservices: kickstarting use of certificates phase II: using certificates for client authentication
There are a number of means of authenticating users, and one of the most secure is via a certificate. This article on CodeProject provides a start. Unfortunately, the article doesn't really mention a few things:
- Depending on how you ran the tools, you may have inadvertently run the commands it gives you as an administrator. I ran them in a console that I already had open that was running as administrator, so they were installed as administrator, and I also happened to have been running in Visual Studio as an administrator at the time, so everything happily worked. Then when I rebooted my machine this morning and was running as a normal user, nothing worked, and I wasted over an hour trying to figure out why. That was why. Regardless of how you generated and installed the keys, you should go and explicitly grant permissions on the key to the users you want to have access to them. On the Microsoft website, there is a bundle of WCF samples (which you can find here). Included in the samples is a tool called FindPrivateKey. Download the samples, compile the program, and use it to find the key that you just generated. You'll need a command similar to the following : "C:\Samples\WCFWFCardSpace\WCF\Tools\FindPrivateKey\CS\bin\FindPrivateKey.exe My LocalMachine -t "28 ce e3 2c 7e 05 3a 97 a0 b4 92 fd d5 b0 f9 de 0e 4c 2e 4b"" where the value in quotes is the thumbprint of the non-signing (client) key you generated in the instructions from the article. Once it spits out the location of the file, you'll need to go and alter its permissions to allow whatever user your server / client application is running under access to the file.
- Depending on the binding you're using with WCF on the server side, you may need to have a certificate with full chain trust on the IIS server (or other?) in order to use the binding (*cough* basicHttpBinding and any other transport-only security bindings *cough*). With that in mind, after you've generated the certificates in the article, while you're in the certificate manager MMC snap-in, you'll also need to copy (not move) the IIS developer certificate used in IIS to the "Trusted Root Certification Authorities" store.
Journey to robust web services: kick starting use of credentials and certificates for message security, phase I
As any sensible developer of a large scale system knows, security is paramount. Therefore, encryption of sensitive data is an absolute must, encryption of all data is recommended, depending on the field in which you're working. Encryption with WCF is baked in, and is relatively straight forward to setup, though there are a number of important details to which attention must be paid. The steps are somewhat different depending on whether you're using IIS or a self-hosted service (e.g. in a Windows Service).
If you're using a Windows Service, you'll need to perform the following steps to get started:
If you're using a Windows Service, you'll need to perform the following steps to get started:
- Generate a self-signed certificate (which can be done in the Windows Control Panel)
- Configure the port to which you're binding the service with the certificate you've just generated, according to this MSDN article.
- [to be continued]
If you're using IIS, getting started in a development environment is somewhat simpler.
- Generate a self signed certificate with IIS. In most cases, IIS will have a developer certificate already installed that you can use.
- Retrieve the thumbprint of the certificate. You'll need this in order for your application to be able to find it at runtime. WARNING: Don't just copy the thumbprint out of the certificate properties window in IIS, because there are non-printing characters in the text control that will cause you problems when you try to paste the thumbprint into your Web.config file. Write them out by hand.
- There are two methods you can take for making the certificate available to your WCF service:
- Follow the guide here if you want to make the certificate available to your application by code.
- Use the information on this page to create a
element underneath a configuration/system.serviceModel/behaviors/behavior/serviceCredentials element.
Sunday, May 05, 2013
Journey to robust web services: my clients are unable to connect!
I've been testing out some web services I've been working on extensively on my own machine, but the time has finally come where I want to start making clients that aren't running on the same machine. In one case, I have a WCF service running on Windows 7, but the client I want to connect to that service is running on Windows 8 on a separate machine. When I tried to connect, I would get a variety of errors, the most common of which being that the socket on the server was forcibly closed. I Googled around a bit, and the most common cause of this problem that I found was that the server's quota's were being reached and therefore the client was being rejected, however this shouldn't have been the case for me since there was no way my quota's could have been reached. After further research, I found that since I don't want security (yet), I had to apply some settings in order for clients that weren't on my localhost to connect. In order to allow external clients to connect, I had to change the following :
- In my
, I had to change my base address to use the network name of my computer (rather than localhost) in the base address URL. - In the net.tcp and ws2007HttpBindings for my services, I had to go to the the
child element of the elements, and explicitly set mode="None" on those elements, otherwise they may assume some form of security by default depending on the type of the binding.
Now, I did mention above that I don't want to add security (*YET*) being the important qualifier of that statement. Security is of course always paramount, and should always be baked into a product as early as possible. As soon as I get to it, I'll add a post about all the steps required to add security to your WCF clients and services, along with links to the relevant MSDN articles (and any other useful ones that I may find.
Subscribe to:
Posts (Atom)