Solution to Error: Save encoded certificate to store failed => 0x5 (5)

While creating a certificate with the MakeCert utility you might face this Error: Save encoded certificate to store failed => 0x5 (5) as I did, dont be worried its not about your command the solution to this is to simply start your command prompt or powershell as an administrator and then run the command; the certificate will be created successfully.

Start Here

New to MohsinKhalid.com? Welcome aboard.

MohsinKhalid is a personal career, lifestyle and travel blog. It’s my outlet to share thoughts and experiences on the work I do, the places I go and the tips I have in general about life.

The blog covers 3 main topics (please click on each to get into more detail):

 Career

Lifestyle

Travel

If you would like to browse through my posts in chronological  order or simply pick a post by category or tag, you can find all content easily on the left sidebar.

#EuropeTour Part 2: 11 Things You Should Not Forget To Pack

So you have gotten your visa and tickets, everything seems to be in order and you are ready to pack for your Europe trip, besides clothes and the stuff you will want to take with you, I want to mention the things you should not forget. So whether you are going in the summer or winter here is what you must have with you.

Image credit: The Disney Den
  1. An empty bottle of water.
  2. Good shoes, its best to have long backs mostly called work boots cause bare in mind you need to walk a lot. I got myself these:
  3. Your own toiletries.
  4. Dry snacks.
  5. A phone that has a good battery, none have a good battery these days so I kept two phones.
  6. Two pin socket adapter, like the ones below (all hotels/hostels have sockets that fit only these) if you dont have one you might have to buy one for as much as 4 euros.
  7. Good quality padlocks, keep at least one extra padlock with you.
  8. A Diary or notebook that contains your hotel addresses(write down the route you plan to take from airport to hotel and from hotel to airport); flight, bus and train details along with the activities you plan to do each day or in each city. This helped me a lot as there is so much to see and so much to do that you might miss out on something you should have included in your trip. Keep this diary with you at all times.
  9. Medicines, pain killers, muscle relaxants and others if you need any.
  10. Plastic bags, lots of them to keep any wet or dirty clothes.
  11. Tissue roll.

Bonus: Earplugs and a sleep mask.

Try to stay as light as possible, keep a 20 – 25 kg suitcase and one backpack that you will carry everywhere. Remember if you are on a budget, even if you are not its always good to take the metro, bus or tram to where ever you want to go, public transport system is really good in Europe specially in Turkey; taxi’s are to be avoided as much as possible; therefore pack keeping in mind that it should be easy for you to travel with all of your stuff. If you plan to take domestic flights then you will have to pay a good amount of money (30-40 euros) just for that suitcase. They allow hand carries that are not more than 10kg. However you can take your suitcase without any extra charge for baggage while travelling through train or bus. Lastly to save space remember to roll and not to fold. Hope this help, stay tuned for more in this series!

Creating an ISV License File from MS Dynamics AX 2012 Model using AxUtil

Us ISVs( Independent Software Vendors) want to make our own customized Ax solutions to run on predefined licenses so we can better monetize our solutions, well thanks to Microsoft we now have an ISV licensing feature to do this and do not need to create our own licensing mechanisms. The ISV licensing feature includes the following key capabilities:

  • ISVs can generate their own Boolean licenses.
  • A run-time check that ensures an ISV-generated license key exists.
Dynamics AX ISV licensing

You can read more about ISV licensing here. In this post I will be showing you step by step how you can create your own ISV licence against a model. Before you can create a license you also need to have certificates in order to sign that license so here are the complete steps from start to end:

  1. First and foremost make sure you implement the desired roles and security in your code and tie all objects in your solution to it.
  2. Create a configuration key (or a parent-child configuration key hierarchy) for the solution.
  3. All code elements must bind to a proper configuration key or a hierarchy of configuration keys.
  4. Make sure all code written for this solution has been moved to ISV layer and to a particular model.
  5. Create a license code in the AOT.
  6. Set the Authenticode (x.509 Certificate) to the license file. Go to the license code properties and find the ‘CertificateName’ item and provide ‘cer’ file (the public part of the certificate, You will use the SPC.cer file for this). Keep the private key (.pfx) part secure as it will be used to generate license file. Here are some details on how to do this:
      1. Locate windows SDK on your machine, usually comes with .Net Framework, in my case I found it at following location

      C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin

      1. Copy following files from above folder to a new folder D:\Certificate folder, this would avoid wasting your time trying to run command on C:\ with no rights
        1. MakeCert.exe
        2. pvk2pfx.exe
    • To create a test certificate you can use the makecert utility, this will give you the .cer and .pvk file; as some of you faced problems with certificates I would like to add something here that I previously missed to mention. To use our own certificate we first need to create a CA(Certificate Authority) and then publish  a code signing certificate through that authority. Creating a certificate authority is done through makecert as follows on power shell run the following command to create a CA:
      • .\makecert -r -pe -n “CN=CompanyName O=CompanyName” -ss CA -sr LocalMachine -a sha256 -len 2048 -cy authority -sky signature -sv CA.pvk CA.cer
    • Now to publish a code signing certificate from our created authority; on powershell run the following command:
      • .\makecert -pe -n “CN=CompanyName O=CompanyName” -ss ISVStore -sr LocalMachine -a sha256 -len 2048 -cy end -sky signature -eku 1.3.6.1.5.5.7.3.3 -ic CA.cer -iv CA.pvk -sv SPC.pvk SPC.cer
    • To create the .pfx file you will need to convert the pvk to pfx; run the following command:
      • pvk2pfx.exe -pvk SPC.pvk -spc SPC.cer -pfx FileName.pfx -po password
  7. Assign the license code to the configuration key. In the parent configuration key, select the license code in the properties. This locks everything together if hierarchy is maintained among other configuration keys.
  8. Generate a FULL CIL.
  9. Export the model by going to Start > Administrative Tools > Microsoft Dynamics AX 2012 Management Shell. Enter following command: axutil export /model:[ModelName] /file:[modelfilename] /key:[keyfilename]
    1. [ModelName] is the name of the model
    2. [modelfilename] is the path with filename to export the model to.
    3. [keyfilename] is the strong name key generated using SN.EXE tool, in the case you want to sign the model with a strong named key. You can skip this part if you apply next step, which is to sign the model using a certificate.
  10. Sign the model with certificate
    1. You need a tool ‘SignTool’. You can get by installing Windows SDK.
    2. Run following command:
      • signtool sign /f “[PFX file]” /p [PFX password] “[Path to the model file]”

Once you have implemented the code with the above approach, you can then generate a license for your solution as explained below:

  1. Axutil genlicense /file:licensefile /certificatepath:filepath /licensecode:name /customer:name /serialnumber:number /password:value /expirationdate:date /usercount:count
    1. /file:licensefile specifies the name of the generated license file
    2. /certificatepath:filepath specifies the path to the certificate used to generate the license file. It is the private part of the X.509 certificate used on the licensed Code within AOT; basically the .pfx file.
    3. /licensecode:name specifies the name of the license code used to generate the license file.
    4. /customer:name specifies the customer name used to generate the license file. This will be provided by the Customer, it will be the Customer name on the AX license they have on their installation.
    5. /serialnumber:number specifies the serial number used to generate the license file. This will be provided by the Customer, it will be the serial number of AX license they have on their installation.
    6. /password:value is the value that must match the password of the certificate used to generate the license file.
    7. /expirationdate:date specifies expiration date of the generated license. This parameter is optional.
    8. /usercount:count specifies the number of simultaneous users for the generated license. This parameter is optional. (This is not supported anymore, so you can skip this)
    9. After running this command you can write “type [licensefilename]” to see the content if the license file.
  2. After you have your license you will share the model file and license file with the customer, also if you have created a self signed certificate(as we did with the makecert utility) then your customer needs to trust your Certificate Authority before they import the model and license. To do this simply run the command below on your customers environment:
    • certutil -addstore Root CA.cer
      • This adds it into the Windows certificate store.

Hope this post was helpful, for any questions feel free to leave a comment. Here are some good resources that helped me understand ISV licensing.

UPDATED: To overcome the “Certificate associated with license XXX is not a trusted certificate.” Error while importing license file the complete steps for creating our own certificate have been update, please find the updates in blue text.

#EuropeTour Part 1: How to apply for a Schengen Visa

So you have planned to visit Europe; however if you are not a US, Canadian or UK resident chances are you are going to need a visa to enter the Schengen Area. I am not a visa expert/counselor so please take the following as my opinion and information based on my experience only.

Europe Schengen Visa
Schengen Visa

The first step is to decide which country you are going to apply to, as the Schengen agreement is accepted by 26 states and you can apply to anyone of them considering that state is going to be your primary destination or first port of entry. I will be talking more about what is best and easiest for Karachites, but most of it will be generally applicable for Pakistanis and residents of a country who require a visa to enter into Europe.

Which country to apply to?

Schengen area map
Schengen States

As I mentioned earlier, you should apply to the country you first want to visit. For example you would apply to Spain for a Schengen visa if you wish to start your tour from Spain. My tour did not include Spain and therefore I had the option to apply to Italy, Germany, Netherlands, France or Switzerland, please remember Turkey is not part of the Schengen agreement but yes you can easily get an E-Visa to Turkey if you have a valid Schengen visa stamp on your passport. I applied to Italy for a few reasons, first and foremost Italy has a consulate in Karachi, Islamabad and Lahore so if you are called for an interview you will not have to travel to Islamabad where all consulates are of other Schengen states. Secondly relations between Pakistan and Italy are fairly good and lastly it is geographically a good point to start seeing Europe in my opinion.

What is going to be your length of stay?

The duration of stay is an important thing to consider before you apply for a visa. If it is your first time travelling and you have a blank passport, keep your duration as short as possible. A week is good to visit one or maybe two countries of your interest. The more days you apply to stay for, the harder it can be for you to get a visa and you will require to show you can afford your trip for the complete duration of your stay.

Should I apply for Single entry or Multiple entry?

Definitely a single entry visa if you have not been to Europe before.

How to apply?

After selecting the state you want to apply to, you will need to read all requirements to apply for a visit visa, some states require more things than others. For Italy, you should have:

  1. 6 month Bank statement of all bank accounts you hold against your name.
  2. Bank account holding certificates of all bank accounts you hold against your name.
  3. A letter from your employer stating your proof of employment.
  4. A letter from your employer stating the dates of your approved leaves and rejoining date.
  5. Tax certificate (Must have)
  6. A health insurance of upto $50,000 (Don’t be worried it is not so costly to get insured)
  7. Confirmed travel tickets.
  8. Confirmed accommodations.
  9. Past 6 months Salary slips.
  10. Any property documents you have (optional)
  11. Recent passport size photographs (white background-non glossy paper)
  12. Passport valid for at least 3 months after visa expiry date.

Please read the consulates website for any updated requirements or information.

How much money do I need to have in my bank account?

The easy rule is to add up the cost of your air tickets, your hotel accommodations and €100 per day for each travel day for example €1700 for 17 days. The total of all this is the minimum amount you should have in your account.

Am I ready to apply?

If you have all of the above, have been in employment for more than an year and have a bank statement to prove that, then your chances are very good. However, if you don’t have any one of the above even the optional stuff your chances will decline fairly. I personally would not advise students or those who are still dependent on others to apply. Most people do not know that if your Schengen visa is refused your passport is stamped with the rejection and certainly that is bad for any future travel plans you may want to fulfill. So please do consult a a good travel agent before applying and get all documents required.

As most of you have requested me for the travel agency I used, it was Pak Shaheen Aviation. They have been my travel agency of choice for the past 4 years, if you do call them ask for Mr. Amjad Ali (+92-343-2703803). You too can get your air tickets, hotels on promotional prices, travel insurance and any tours your would like from them as I did. If you have any further questions about the visa process, let me know through your comments below and stay tuned!

My 17 Day Tour of Europe: Planning, Cost and Useful Tips for Future Travelers

As an avid traveler, I too have a goal of visiting a specific number of countries during my lifetime but lets leave that for another day. I love to travel and last month I fulfilled one of dreams and had the opportunity to tour Europe. My destinations were Turkey, Italy, Germany, Netherlands, France and Switzerland in that order. I explored a small circle containing the best and most famous attractions of the world going from eastern Europe towards western Europe.

Europe map
Map of the European Tour

It was an amazing experience, one that is hard to describe and can only be felt and witnessed. I would like to share part of that experience by describing how I planned and spent my time in the most beautiful and famous cities of Europe. I will be sharing my personal experiences, advice about what to pack, where to stay and the best and cheapest ways to travel, some pictures of course and any other useful tips I can think of. I aim to provide this information for future travelers in a series of posts to follow. I will be writing a blog for each city I visited, so readers can bookmark this page or follow me on Twitter if they would like to stay tuned. I will also be adding links to the complete tour series at the bottom of this post. Most importantly, I will be sharing valuable visa advice specifically for Pakistanis interested in creating their own travel adventures in Europe.

Destination Istanbul
Where my great experiences began!

Now, for some basic details about the tour in general. The tour was  17 days days long, starting from 18th December 2014 and ending on 3rd January 2015, during the winter season. The trip cost me PKR  350,000 ($3500) and the breakdown of costs will be included in the series of posts to follow. The cities  I visited were Istanbul, Rome, Berlin, Amsterdam, Paris and Zurich. I stayed mostly in 3 star hotels and one famous hostel in Berlin. I traveled using domestic airlines, buses and a high speed train to get from city to city. To conclude, I would like to mention that if anyone has any questions / any specific topic they would like me to address in detail in the following posts, they can simply comment below and I’ll try to answer as well as possible. Stay tuned!

 

UPDATE:

#EuropeTour Part 1: How to apply for a Schengen Visa

#EuropeTour Part 2: 11 Things You Should Not Forget To Pack

 

Difference between menu item types; Display, Output and Action in Dynamics Ax

Menut item types

 

Developers often ask me what the difference is between the three different menu item types shown in AOT and when should you use them as it appears that all menu items inside the three ‘folders’ I would say have the same set of properties and support the same object types. So what is the difference? The answer is that there is no difference, the difference is a conceptual one rather than a functional or a technical one.

1. Display Menu item

This folder is used to contain menu items that reference runnable objects which are primarily for presenting data to the user such as forms and dialog’s.

2. Output Menu item

An output menu item should have the soul purpose to print a result, mostly used for referencing classes.

3. Action Menu item

As the name says it, you should create a menu item under this folder if your runnable object has an action to perform, for example creating or updating data.

So choosing between these three is on the developers sole discretion and I hope now you’ll be able to make a better choice for your scenario. A basic rule of thumb is:

Display – for Form

Output  – for Report

Action   – for classes.

For more information visit :  Msdn Menu Items Best Practices [AX 2012]