23 March 2014

Setting up Windows Phone SDK on Windows 8 64-bit

Windows Phone 8 is the second and current generation of the Windows phone mobile operating system from Microsoft. Launch of Windows Phone 7 was a big step by Microsoft in mobile development. Though it was not a great success, it marked the platform for Windows Phone 8. There are two areas in which Windows Phone 8 differs from its predecessor: the core of the OS has been updated with the NT kernel and the addition and refinement of features. The new OS is closely integrated with the Windows 8 desktop operating system.

The user base for Windows Phone is increasing day by day and so with it, the app requirements. With easy development tool and minimal deployment charge on app store, many developers are joining each day to windows developer community. This post is just a step by step procedure to setup Windows Phone SDK. This being said, you'll need Windows 8 and Visual Studio 2012 or greater on your system to start development. Most of the steps will be same as Getting started guide at msdn but I faced some problems while installing it, so I will be discussing them too.

Step 1: Download the developer tools -
Download the Windows Phone SDK 8.0 which includes all the tools you need to create Windows Phone apps namely Microsoft Visual Studio Express 2012 for Windows Phone, Project Templates, Windows Phone Emulator and much more. You can get the SDK from here. Just download the SDK 8.0 from the link and it should do the job for you. Also download the Windows Phone SDK 8.0 Update 3 Emulators if you want to get 5 new emulators. You can download the SDK 8.0 Update for Windows Phone 8.0.10322.
If you are using Visual Studio 2012, its better to install Update 4 for latest version of sdk to work otherwise it will give you compilation errors. You can download the Visual Studio 2012 Update 4 from microsoft site.
For other types of tools you can go the Developer Downloads for Windows Phone link.

Step 2:  If you want to test the app on your Windows Phone, you'll need a registered one. Prerequisites for registering the phone is the SDK, so you'll need to install them first. Then you'll need a your Windows live ID. Each live ID allows you to register one phone for development purpose. Preferably you can join developer account in which case you can register 3 phones for development purpose. Developer account costs you some nominal charges annually to deploy your apps on the Windows App Store. After installing the SDK, follow the steps given below to register your phone -
 i) Turn on your phone and unlock the phone screen.
 ii) Ensure date and time are correct.
 iii) Connect your phone to the computer using the USB cable.
 iv) Press Windows start button and search for Windows Phone Developer Registration.
 v) Verify that the Status message displays Identified Windows Phone 8 device. Click the Register button to        unlock the phone. Then click Register.
 vi) In the Sign In dialog box for your Microsoft account, enter the Microsoft email address and password          and click Sign In.
 vii) After your phone is successfully registered, the Status message displays Congratulations! You have               successfully unlocked your Windows Phone.
 viii) After this, go to your phone Settings > Phone Updates and check for updates. Install the updates if any         and restart the phone.

Now you are ready to write windows applications. To start with a sample application, you can start visual studio and click on new project option. Windows phone apps are not restricted to a single language. You can develop using Visual Basic, C#, C++ or JavaScript. Except JavaScript, you can find all other template projects in your visual studio's new project option. Just select the particular starting template and start developing. Though for JavaScript, you'll have to use Phonegap or Cordova. I won't be discussing about Phonegap development in this post. After compiling your Windows Phone project in Visual Studio, you can run it on your connected and registered phone or test it on emulators installed with the SDK. Execution options can be selected from the drop-down execute button. You can checkout other deployment and troubleshooting options here.

Installing Windows Phone SDK is not enough if you are going into full fledged development. Here are the few tools you might need to integrated into your project while developing your apps based on requirements. Mostly these tools can be easily integrated using NuGet in Visual Studio. Visual Studio 2012 or later already comes with NuGet Package Manager integrated into it, in the Tools option. If you are using older version, make sure you install NuGet into Visual Studio. Tools you must know about -
1. The Windows Phone Power Tools - These are a natural extension to the developer tools that come with the windows Phone SDK. Instead of allowing you to only install developer xaps the Power Tools let you test update scenarios by allowing you to update an existing developer app. Instead of having to step through the IsolatedStorage file browser on the command line, the Power Tools provide a GUI to allow you to interact with your applications.
2. Multilingual App Toolkit - This toolkit can be used inside Visual Studio to streamline your localization workflow for Windows Store and Windows Phone apps. The toolkit helps you localize your apps with localization file management, translation support, and editor tools.

3. Windows Azure Mobile Services - This client library enables client applications to connect to Windows Azure Mobile Services. Mobile Services allows you to develop an app with a scalable and secure backend hosted in Windows Azure. You can incorporate structured storage, user authentication and push notifications in minutes. You can install this library for C# using NuGet Package manager console and type the following command -
      Install-Package WindowsAzure.MobileServices 

4. The Windows Phone Toolkit - This toolkit is straight from Microsoft Windows Phone developer platform team. This toolkit provides the developer community with new components, functionality and an efficient way to help shape product development. WPToolkit releases include open source code, samples and docs, plus design-time support for the Windows Phone platform. These components are required in most basic apps and are not present directly in Windows component toolkit. You can install this library for C# using NuGet Package manager console and type the following command -
        Install-Package WPtoolkit

5. Coding4Fun Toolkit  - This toolkit has multiple controls and useful items such as GzipWebClient and Audio Recorder for XAML based applications. The complete version of the toolkit also includes the network, storage wrappers, controls, and audio helper libraries. Type these commands in NuGet Package manager console to add the complete version of toolkit to your C# windows phone project -
  Install-Package Coding4Fun.Toolkit.Complete

18 January 2013

Making your own Digital Certificate for Code Signing using OpenSSL

These steps will guide you to make your own public key certificate for digital signatures. There are many tools on the net to do this. This uses OpenSSL and gives you a certificate with a chain to your root CA.

Step 1: First we generate a 4096-bit long RSA key for our root CA and store it in file ca.key:
openssl genrsa -out ca.key 4096
Generating RSA private key, 4096 bit long modulus
is 65537 (0x10001)

If you want to password-protect this key, add option -des3.

Step 2: Next, we create our self-signed root CA certificate ca.crt; you'll need to provide an identity for your root CA:
openssl req -new -x509 -days 1826 -key ca.key -out ca.crt

You are about to be asked to enter information that iwll be incorporated into your certificate request.
What you are baout to enter is what is called a Distinguished Name or DN. There are quite a few fields but you can leave some blank For some fields there will be a default valu, If you enter '-', the filed will be left blank.
Country Name(2 letter code) [GB] : IN
State or Province Name (full name) [Berkshire]: TestProvince
Locality Name (eg, city) [Newbury]: TestCity
Organization Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) [] :
Email Address []:

The -x509 option is used for a self-signed certificate. 1826 days gives us a cert valid forr 5 years.

Step 3: Create our subordinate CA that will be used for the actual signing. First generate the key:
openssl genrsa -out ia.key 4096
Generating RSA private key, 4096 bit long modulus
e is 65537 (0x10001)

Step 4: Then, request a certificate for this subordinate CA:
openssl x509 -req -days 730 -in ia.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out ia.crt
Signature ok
subject=/C=BE/ST=TestCity/L=TestCity/O=https://fdf.com/ON .......
Getting CA Private Key

The cert will be valid for 2 years (730 days) and I decided to choose my own serial number 01 for this cert(-set_serial 01). For the root CA, I let OpenSSL generate a random serial number.

That's all there is to it! Of course, there are many options I didn't use. Consult the OpenSSL documentation for more info.

Step 5: To use this subordinate CA key for Authenticode signatures with Microsoft's signtool, you'll have to package the keys and certs in a PKCS12 file:
openssl pkcs12 -export -out ia.p12 -inkey ia.key -in ia.crt -chain -CAfile ca.crt
Enter Export Password:
Verifying - Enter export Password:

To sign executable in Windows with the signtool: install file ia.p12 in your certificate store and then use signtool to sign your PE file.

1. http://blog.didierstevens.com/2008/12/30/howto-make-your-own-cert-with-openssl/#comments
2. http://www.openssl.org/docs/apps/openssl.html
3. http://www.openssl.org/related/binaries.html
4. http://en.wikipedia.org/wiki/OpenSSL