IPv6 is such messed up and not supported, it’s a shame.

The idea I had was to move my local subversion repositories to a dedicated server where I wanted to create virtual machines that are directly bridged to the internet. To give a little bit more security I also needed SSL encryption. Because IPv4 is getting to an end and the ip adresses are really expensive, I decided to use IPv6.

That’s where my journey started and where my horrible days begun. I try to show you what issues I had to face and which solutions I had to solve those issues.

First of all, because it’s an server that shall do nothing than serving my code, I decided to install Windows 2012 Server Core. That’s not the worst, but you are really forced to learn Powershell – which is the good side at this, because I think that I had a good learning curve.

Issue 1 – Accessing Apache:
First of all I installed the CollabNet Subversion Server which does include the Apache Server as well. The download can be found here (http://www.collab.net/downloads/subversion). The server installation was quite easy, but I did not manage to access it from another PC.

After all I found out, that the installation process did not create a proper firewall rule in order to access the SubVersion Repository. The following power shell lines did the trick:

new-netfirewallrule -DisplayName Apache -Name Apache -enabled 1 -profile any -protocol tcp -direction inbound -localport 80
new-netfirewallrule -DisplayName ApacheSSL -Name ApacheSSL -enabled 1 -profile any -protocol tcp -direction inbound -localport 443

But that’s not the only thing that needs to be done. Furthermore the httpd.conf in (C:\Program Files (x86)\CollabNet\Subversion Server\httpd\conf\httpd.conf) needs some adjustments.

The following lines must be included or commented in:

LoadModule dav_module modules/mod_dav.so
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

And add the end of the file the location section needs to be inserted:

<Location /svn/Repository>
   DAV svn
   SVNPath E:\SubVersion\Repository
   AuthType Basic
   AuthName "Subversion repository"
   AuthUserFile E:\SubVersion\svn-users
   Require valid-user
</Location>

As you may noticed, there’s also a svn-users file referenced that needs to be created. In order to create the svn-users file copy the htpasswd.exe from (C:\Program Files (x86)\CollabNet\Subversion Server\httpd\bin) to your subversion repository parent folder (e.g. e:\SubVersion). Than you can create the users with the following lines:

htpasswd -cm svn-users USER1
htpasswd -m USER2

Last but not least, we need a new subversion respository. This can be created with the following line of code:

svnadmin -create E:\SubVersion\Repository

After that I had to restart my service:

restart-service CollabnetSubVersionApache

If you made no mistake you should be able to access your new repository by typing the following URL to the browser:

http://SERVER/svn/Repository

Issue 2 – Create SSL Certificate:
The second problem was to create a self-signed SSL Certificate that can be used by the Apache installation. Therefore I first downloaded the OpenSSL from (http://slproweb.com/products/Win32OpenSSL.html) and than created a directory (C:\Program Files (x86)\CollabNet\Subversion Server\httpd\conf\ssl) where I created the key with the following powershell lines.

openssl req -new -out developer.csr -keyout developer.pem
openssl rsa -in developer.pem -out developer.key
openssl x509 -in developer.csr -out developer.cert -req -signkey developer.key -days 16000
openssl pkcs12 -export -in developer.cert -inkey developer.key -out developer.pfx

Remember to give a common name, because this is needed by Apache. The Key can now be referenced in the httpd-ssl.conf file in (C:\Program Files (x86)\CollabNet\Subversion Server\httpd\conf\extras\httpd-ssl.conf). So it looks like this:

SSLMutex default
SSLSessionCache none
SSLPassPhraseDialog builtin


Listen 443


<VirtualHost _default_:443>
   ServerName localhost
   DocumentRoot "C:\Program Files (x86)\CollabNet\Subversion Server\httpd\htdocs"
   SSLEngine On
   SSLCertificateFile "C:\Program Files (x86)\CollabNet\Subversion Server\httpd\conf\ssl\developer.cert"
   SSLCertificateKeyFile "C:\Program Files (x86)\CollabNet\Subversion Server\httpd\conf\ssl\developer.key"
   ErrorLog "C:\Program Files (x86)\CollabNet\Subversion Server\httpd\logs\ssl.log"
   TransferLog "C:\Program Files (x86)\CollabNet\Subversion Server\httpd\logs\transfer.log"
</VirtualHost>

In order to get this file used by the Apache Server you have to include the following lines of code in your httpd.conf file (C:\Program Files (x86)\CollabNet\Subversion Server\httpd\conf\httpd.conf).

# Secure (SSL/TLS) connections
LoadModule ssl_module modules/mod_ssl.so
Include conf/extra/httpd-ssl.conf<


<Location /svn/Repository>
   DAV svn
   SVNPath E:\SubVersion\Repository
   AuthType Basic
   AuthName "Subversion repository"
   AuthUserFile E:\SubVersion\svn-users
   Require valid-user
   SSLRequireSSL
</Location>

If you made no mistake (the second time) you should be able to access your repository by typing the following URL to the browser:

https://SERVER/svn/Repository

Sure, you’ll get a security warning, because of the self-signed certificate, but that doesn’t bother us. It should work anyway.

Issue 3 – Apache and IPv6:
I thought that to disable IPv4 should be sufficient in order to work solely with IPv6. But far wrong. You can disable IPv4 with the following command.

disable-netadapterbinding -Name Ethernet -ComponentId ms_tcpip

But from that point on, you are not longer able to access your Subversion repository. Even not with one of the shiny new URLs that you can type in your browser like:

https://[bfe80::b9d4:8109:6177:becb]/svn/Repository/

So I had been forced to reenable IPv4 protocol. And to search for a solution.

enable-netadapterbinding -Name Ethernet -ComponentId ms_tcpip

After googling around I found out, that the standard build of SubVersion for Windows has not been compiled with the IPv6 feature included. But this fact is stated nowhere. You have to learn it the hard way. After googling longer I found a binary compile at a japanese site that has been built including IPv6 support. Lucky about that finding, I installed the following download: http://win6.jp/Apache22/index.html

Important: Be carefull and get your config files saved before you overwrite the Apache installation at “C:\Program Files (x86)\CollabNet\Subversion Server\httpd\”. And don’t forget to stop the Apache Service, because otherwise you can’t exchange the files, because they are in use.

After this expirement you should be able to access your repository with IPv6 in Browser by typing the following URL.

https://[bfe80::b9d4:8109:6177:becb]/svn/Repository/

Issue 4 – TortoiseSVN Client and IPv6:
After all this research I thought that everything is fine. But far wrong. TortoiseSVN was the next candidate that failed as I tried to browse the subversion repository.

I googled around the whole afternoon, but the only suggestion I found, was to compile TortoiseSVN at your own (which needs a whole bunch of complicated tools to use) or to use the Nightly Build which should have IPv6 enabled. Sure I tried to install the NightlyBuild of TortiseSVN, but also with that I wasn’t able to access the repository with the IPv6 URL.

So all in all I gave up after two days of research. I guess the world has still too much IPv4 Adresses and the pressure has not been high enough for all the tool provider in order to implement support of IPv6 these days. So in my eyes, IPv6 is such messed up and not supported, it’s a shame. Perhaps I try it in 10 years again …

Windows Server Core 2012 – Remote configuration

If you want to be a real nerd, then you have to configure your windows server 2012 as a core server. That means without any UI ;)

Because I always want to be “nerdy”, I did that.

The problem is that you only have a dos command promt and a powershell that can help you. Remote Configuration could be handy, but that isn’t accessible out of the box.

To enable remote configuration, you’ll have to open the powershell at the server and enter the following lines:

Server:
Set-WSManQuickConfig
Enable-PSRemoting
Enable-NetFirewallRule -DisplayGroup "File And Printer Sharing"

If you are just using a workgroup without a domain (like me), you’ll have to add your shiny new server to the TrustedHosts list at your client PC too.

So open a powershell at your client and replace the placeholder {server} with your server name :

Client PC:
Set-Item wsman:\localhost\Client\TrustedHosts {Server} -Concatenate -Force

Now you could open the server with the MMC, but we want to be “nerdy”.
So the only thing that’s left, is to install the Server Manager at your Windows 8 PC to ease your work.

The Server Manager can be downloaded from here:
http://www.microsoft.com/en-gb/download/details.aspx?id=28972

Enjoy ;)

Android APK Code Signing

After searching for a simple solution on how to sign an APK package for deploying in the Google Play store, I found a simple three step cookbook that was very easy to read and understand.

http://www.coderzheaven.com/2011/04/01/android-signing-apk/

Although I stepped into one pitfall due to the used JDK version, in the end it was successfully. If you installed JDK 1.7 the code-signing won’t work. This has to do with an incompatibility of the KeyTool Binaries. The only way to get it work, is to completely remove JDK 1.7 and install the latest JDK 1.6 (Update 33).

Generating a PKCS12 (PFX) file for SSL Certificate Store in Azure

It’s always the same – some nice day your SSL certificate expires – or you even don’t have your own certificate right now. Than one questions may drive you crazy: How do I get a PFX file out of the damn .CER certificate file I bought?

First of all: cool down. A .PFX File is nothing else but a .CER certificate file that includes the private .KEY key file, which you both got from your certificate provider.

With that knowledge behind you can download OpenSSL for Windows from the following website: http://slproweb.com/products/Win32OpenSSL.html
OpenSSL offers you a nice command line option for converting your certificate:

openssl pkcs12 -export -in my.cer -inkey my.key -out mycert.pfx -password pass:mypass

The command line options in detail:

-in <certificate> That’s your certificate file you got from your certificate provider
-inkey <keyfile>  That’s the private key file you got from your certificate provider
-out <pfxfile>  That’s the pfx file you want to create
-password pass:<password> The password to protect your created pfx file

After that you can upload your SSL certificate to Azure – and everything works fine ;)

Hosting/Debugging WCF Service with 32 Bit WCFServiceLibrary

These days I had the problem that I needed to host and debug 32Bit WCF Service in Visual Studio 2010, because my backend had to talk to a Access Database where no 64Bit Driver is available.

But always when I tried to do that, I got the following exception:
System.BadImageFormatException: Could not load file or assembly

After googling around the web I found out, that the WcfServiceHost in VS2010 is not able to accept 32 Bit DLLs. But I also found a clever solution how to fix it.

  1. Copy WcfSvcHost.exe from C:\program files (x86)\Microsoft Visual Studio 9.0\Common7\IDE to a local directory. Keep a backup copy of this file, of course.
  2. Start a Visual Studio 2010 Command Prompt (one of the links from the start menu -> Visaul Studio 2010)
  3. “cd” to the directory where your copy of WcfSvcHost is located.
  4. Execute the command “corflags /32BIT+ /FORCE WcfSvcHost.exe”
  5. Copy the exe back to where you found it.

That solution works very great and should solve your problem as it did solve my.

Thanks and respect to Marco Zhou and Gordon Watts who found out this solution:
http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/2e29a4aa-e587-43ef-bf50-329b7cd3eefb/

Help making Windows Phone 7 Emulator to be Virtual Machine enabled

Microsoft has setup a page on User Voice in order to improve development environment for Windows Phone 7 applications.

Because of my Windows Phone 7 Apps “TimePunch Mobile” and “My Colouring Book”, I’m already used to it. But it’s really annoying that the emulator can’t run within a Virtual Machine.

That’s why I need YOU and your UserVoice to make Microsoft move their ass and improve the emulator so that it can run within a VM.

Please vote for it on: http://wpdev.uservoice.com/forums/110705-app-platform/suggestions/2344692-enable-the-emulator-to-run-in-vm-s-virtual-machin

Using AutoMapper Config with ValueInjecter

For all who are interessted, I created a ValueInjecter extension in order to use your existing AutoMapper Mapping Configuration with ValueInjecter. I created this extension because I had to switch over to ValueInjecter, because I could not compile AutoMapper against Client Framework 4.0. And I didn’t wanted rewrite my Mapping Configuration.

It looks like the AutoMapper, but internally it uses ValueInjecter ;) Hope you enjoy the extension.

Example:

public class CalendarEvent
{
    public DateTime EventDate { get; set; }
    public string Title { get; set; }
}

public class CalendarEventForm
{
    public DateTime EventDate { get; set; }
    public int EventHour { get; set; }
    public int EventMinute { get; set; }
    public string Title { get; set; }

    // Additional Members to show further mapping possibilities
    public string BarToIgnore { get; set; }
    public bool AlwaysTrue { get; set; }
}

static void Main(string[] args)
{
    // You can use the AutoMapper extension for the ValueInjecter like you would user AutoMapper

    // Model
    var calendarEvent = new CalendarEvent
    {
        EventDate = new DateTime(2008, 12, 15, 20, 30, 0),
        Title = "Company Holiday Party"
    };

    // Configure AutoMapper
    Mapper.CreateMap<CalendarEvent, CalendarEventForm>()
        .ForMember(dest => dest.EventDate, opt => opt.MapFrom(src => src.EventDate.Date))
        .ForMember(dest => dest.EventHour, opt => opt.MapFrom(src => src.EventDate.Hour))
        .ForMember(dest => dest.EventMinute, opt => opt.MapFrom(src => src.EventDate.Minute))
        .ForMember(dest => dest.Title, opt => opt.MapFrom(src => src.Title))
        .ForMember(dest => dest.BarToIgnore, opt => opt.Ignore())
        .ForMember(dest => dest.AlwaysTrue, opt => opt.UseValue(true));

    Mapper.AssertConfigurationIsValid();

    // Perform mapping
    CalendarEventForm form = Mapper.Map<CalendarEvent, CalendarEventForm>(calendarEvent);

    // Assertions
    Debug.Assert(form.EventDate == new DateTime(2008, 12, 15));
    Debug.Assert(form.EventHour == 20);
    Debug.Assert(form.EventMinute == 30);
    Debug.Assert(form.Title == "Company Holiday Party");
    Debug.Assert(form.BarToIgnore == null);
    Debug.Assert(form.AlwaysTrue == true);
}

You can download the extension from: http://wordpress.ad-factum.de/AutoMapperConfig_UsingValueInjecter.zip

And if you like it, I really would appreciate an UpVote on StackOverflow ;)

UPDATE
And because of dhollifield (see comments) I updated the code so that unmapped properties are getting an automatic mapping. It saves time for the most mappings, but keep in mind that this enhancement is not exchangeable with the AutoMapper anymore.

Call the Method “MapUnmappedProperties” in the automapper configuration in order to use this feature. The updated code can be downloaded from here : http://wordpress.ad-factum.de/AutoMapperConfig_UsingValueInjecter2.zip

Posted in .NET, C#. 5 Comments »
Follow

Get every new post delivered to your Inbox.

Join 106 other followers