HiGohr,
the attributes needed by a token to create an X509Certificate depends on the token itself. A template may be valid for a token and may be not valid for another kind of token.
In your case may be your token requires the attributes
CKA_CERTIFICATE TYPE
Try to add this line in your template:
template.Add(new ObjectAttribute(ObjectAttribute.CKA_CERTIFICATE_TYPE, Certificate.CKC_X_509));
If this still doesn't work you should try with a different set of attributes in the template.
See this page on ncryptoki wiki to know what are the other attributes you can use for a certificate:
http://wiki.ncryptoki.com/How-to-import-an-X509-Certificate.ashx
Regards,
Ugo Chirico
http://www.ugochirico.com