SQL-Server service won’t start after enabling SSL

Maybe you followed this guide to enable SSL for your SQL-server instance, but when you thought you were ready, the service won’t start.

What to do next?

A good guess is that your SQL-Server error log tells you “Unable to load user-specified certificate [Cert Hash(sha1) “XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”]. The server will not accept a connection. You should verify that the certificate is correctly installed. See “Configuring Certificate for Use by SSL” in Books Online.

You can find out by logging in to SQL Server Management Studio and expand your server->Management , right-click SQL Server Logs and select View->SQL Server Log. When the Log File Viewer appears, press Filter, under Message contains text enter SSL och check the box Apply filter.

If the line above appears in your log, my guess is that your SQL-Server service account do not have the right to access the certificates keys.

And the solution?

First of all, you need to find out what account runs you SQL-Server service. It probably should be a domain account, but in my case (lab environment) i used NT Service\MSSQLSERVER.

Then, open up MMC and add the Certificate snap-in. (You probably know how, but otherwise it’s in the guide above on how to enable SSL). Locate your certificate, right-click and select All Tasks->Manage Private Keys. Probably,, your SQL-Server service account is missing in that list. If so, click add and locate your service account. If you, like me, are using NT Service\MSSQLSERVER, just select your local server as Location and paste NT Service\MSSQLSERVER into the textbox. Then click OK. In the checkboxes below the accounts, make sure to give the service account the read permission.

Now, go back to Sql Server Configuration Manager and try to start the service again. It should work now!

A10 aFlex: Temporary blacklist clients based on failed logins

I was asked if i could find a way to temporary blacklist clients after x failed logins. The reason was to avoid lockout in AD when users changed their passwords, but forgot to change the password in their phones connected through ActiveSync.

If a phone connects to ActiveSync with the wrong password, resulting in a error 401, i should be able to catch that and save the IP in a table. If it re-occurs 4 times or more in less then 10 minutes than the A10 should remember this and drop the traffic, resulting in request not being sent to the mail server and the AD account not being locked out.

Thats the theory. Below is my current solution, very much in POC state but my initial testing looks promising 🙂 But i’m sure there are many aFlex/TCL gurus out there to correct me. I’m certainly not one of them!

A few notes:

  • Because i write failed attempt to temp-table, the blacklist is 10 minutes after the last failed logins. This is probably longer than needed.
  • maxfadiledrequests is set to 5, because it always start at 2 for me.. and i’m not sure why. I did expect it to start at 1 since the initial status from server is 401, but not 2.
  • holdtime is the the in seconds the address is blocked
  • You should probably not write to log in a production environment


Xamarin Droid: Putting LocationManager in a separate class

I almost always put all logic in som sort of separate classes in my projects. I simply think it looks better, is way more easy to understand and the better way.

When using Xamarin to create cross-plattform apps, you probably use dependency injection to minimize ugly code blocks like this.

That also means you pretty much need to create interfaces that you can use for all plattforms, which leads to this topic: You need to put logic in classes.

I had a bit of a struggle to implement location services on Android this way, hence this post. Most bloggs and articles i found used the main activity. For iOS it was very straight forward, so I’m leaving that part out.

And to be clear: This is my POC-code, not intended to copy and paste into production!

First of all, i had to create an interface i could use for iOS and Droid. I kept it simple, and only included stuff i needed: The current location, a method to initialize everything and a event to trigger when position changes.

I also created i class holding the main activity context. I needed this to be able to use the context from my class.

In my MainActivity i set the context of the class above:

From my cross-plattform code i need to get a instance of ILocationManager for the current plattform. For this, i use the DependencyService. I Also call my StartLocationUpdates method to start getting location updates:

So far, all code except the config class is the same for both iOS and Android. But this is where i hit the wall on Android. I spent days trying to figure out how to create a class using my interface that would work in the same way my iOS code did. This is my solution

First, make sure to put this line above the namespace in your class to get dependency injection to work:

The second thing i found important was to decorate your class with the Activity attribute. This makes sure your activity is inserted into the Manifest, which is important. You also need to inherit Activity class, and implement your interface.

The rest is kind of straight forward. You need to implement a few methods because of the inheritance of Activity, and of course your own interface.

Here is my complete code:

Not that hard, once you figured it out. Happy coding!

Am i the only one who rewrites the same project over and over again? :)

Am I the only one why keeps rewriting the same code, over and over again, while learning new languages or plattforms?

For me, it’s mainly because i hate to run Hello world examples or create meaningless projects. Because of that, my hobby project NautiCalc (you can find i web version right here) has been rewritten in PHP, Objective-C, Java, Javascript  on plattforms like iOS, Android, Web and OS X.

And now, it’s time again! Last week I attended to DevSum 2016, and I got totally hooked by Xamarin! Time to build a cross-plattform version, running on iOS and Android!

After 3-4 days of coding with Xamarin on my Mac, my first reactions are:

  • Xamarin studio is surprisingly  complete, and supports pretty much everything you need!
  • Creating UI in XAML is really nice! I’ve missed it since i dropped Silverlight.
  • Xamarin.Forms is really nice and makes it easy to write cross-plattform apps. The best thing is that it maps to native components for each plattform.
  • The built-in dependency injection adds to that!

NautiCalc in Xamarin

So, my main screen is built up by a TabbedPage built with XAML. In this page all i do is adding my namespace, so i can reference separate pages for each tab, instead of have one huge XAML file.

The TabbedPage render native navigation menus for each plattform. IT works with Windows as well, but who cares about Windows phones?

Below you can see the about page on Android and iOS, where the navigation is created by the XAML in my TabbedPage. The Android version lacks graphics at this moment,



The XAML for the about page above is also the same on both plattforms. There’s only one thing thats different on each plattform, and that is the margins:

And, off course, there’s a small code behind as well. We need to add a GestureRecognizer to enable click on the hyperlinks:

My NavigationPage (the main screen in the app) uses Xamarin.Forms.Maps. This package has to be installed from NuGet, and it also requires some initiation and for Android som configuration like API key. When that is done, map component renders Apple Maps on iOS, Google Maps on Android and Bing Maps on Windows. All with the same code!



Cross-plattform have never been easier, and ism deeply impressed by both Xamarin Studio and the framework!

Time will tell if the app finishes, or maybe i’ll change my mind and rewrites this project before it gets done. Who knows 🙂

How to create Websites (and more) with PowerShell?

If you, like me, are maintaining lots of websites, you probably want to script as much as you can. It’s time consuming to change a setting for 20+ websites, and it’s also a great chance you miss something in the process.

PowerShell is really neat in these cases, and it gets better for every new release as well.

This is a script i use to do the following:

  1. Create a new application pool, with the preferred .NET version, identity and a few other settings
  2. Create a folder to hold the website
  3. Create the website
  4. Configure a scheduled task to rotate and archive log files.

This script is highly customized for my needs and my environment. As you can se there’s a lot of assumptions in the script, that you may want to change, but i may be a nice start for you!