- 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.
Showing posts with label certificates. Show all posts
Showing posts with label certificates. Show all posts
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:
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.
Subscribe to:
Posts (Atom)