<link>http://www.ncryptoki.com/forum.aspx</link> <description /> <docs>http://www.rssboard.org/rss-specification</docs> <generator>mojoPortal Forum module</generator> <item> <title>Re: Creating X509 certificates In the template for generating a certificate, in the CKA_VALUE you should set a DER encoded X509 certificate not a random number.
Also, you set some attributes that are not valid for a certificate, such as MODULUS_BIT.

If you want to generate a key pair you should use the generateKeyPair method.
Then, to generate a certificate you should call a CA.]]>
http://www.ncryptoki.com/Forums/Thread.aspx?pageid=9&t=71~-1#post338 hyfakih http://www.ncryptoki.com/Forums/Thread.aspx?pageid= Wed, 17 Oct 2012 08:42:35 GMT Creating X509 certificates
                byte[] data = new byte[512];
                RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
                rng.GetNonZeroBytes(data);


               CryptokiCollection template = new CryptokiCollection();
                template.Add(new ObjectAttribute(ObjectAttribute.CKA_CLASS, CryptokiObject.CKO_CERTIFICATE));
                template.Add(new ObjectAttribute(ObjectAttribute.CKA_SUBJECT, "hello world"));
                template.Add(new ObjectAttribute(ObjectAttribute.CKA_ISSUER, "Company Name"));
                template.Add(new ObjectAttribute(ObjectAttribute.CKA_SERIAL_NUMBER, "96663-121212-qwewqe-213123"));
                template.Add(new ObjectAttribute(ObjectAttribute.CKA_ID, 1));
                template.Add(new ObjectAttribute(ObjectAttribute.CKA_LABEL, "Cert-1"));
template.Add(new ObjectAttribute(ObjectAttribute.CKA_TOKEN, true));
template.Add(new ObjectAttribute(ObjectAttribute.CKA_VALUE, data));
template.Add(new ObjectAttribute(ObjectAttribute.CKA_EXTRACTABLE, true));
template.Add(new ObjectAttribute(ObjectAttribute.CKA_MODULUS_BITS, 4096));
template.Add(new ObjectAttribute(ObjectAttribute.CKA_MODIFIABLE, true));
CryptokiObject certificate = session.Objects.Create(template);

return (Cryptware.NCryptoki.X509Certificate)certificate;                  

 

 

 

and it is showing error n.18

]]>
http://www.ncryptoki.com/Forums/Thread.aspx?pageid=9&t=71~-1#post337 hyfakih http://www.ncryptoki.com/Forums/Thread.aspx?pageid= Wed, 17 Oct 2012 07:39:15 GMT