Note that there are some explanatory texts on larger screens.

plurals
  1. POThe template parameter in InitializeFromPrivateKey() on CX509CertificateRequestPkcs10 object causes exception when trying a specific Template
    primarykey
    data
    text
    <p>I am having an issue with specifying the template parameter in <em>InitializeFromPrivateKey()</em> on the <em>X509Enrollment.CX509CertificateRequestPkcs10</em> object. Anything other than a template of <em>"User"</em> is resulting in the following exception:-</p> <p><strong>CertEnroll::CX509CertificateRequestPkcs10::InitializeFromPrivateKey: The requested certificate template is not supported by this CA. 0x80094800 (-2146875392)</strong> </p> <p>There is a specific Certificate template that I need to be used, and when I try it then the code throws the exception. The template exists on the CA, and on the client machine which is running the following code.</p> <p>Javascript code as follows:</p> <pre><code> &lt;script type="text/javascript"&gt; var sCertificate = null; var sDistinguishedName = "C=\"\";S=\"\";L=\"\";O=\"XXXXX\";OU=\"XXXXXXX\";E=\"XXXXX@XXXX.com\";CN=\"xxxxxxx\";"; var template = "RegistrationCert"; //Anything Other than "User" fails, have tried template Oid too. var classFactory = new ActiveXObject("X509Enrollment.CX509EnrollmentWebClassFactory"); var objEnroll = classFactory.CreateObject("X509Enrollment.CX509Enrollment"); var objPrivateKey = classFactory.CreateObject("X509Enrollment.CX509PrivateKey"); var objRequest = classFactory.CreateObject("X509Enrollment.CX509CertificateRequestPkcs10"); var objDN = classFactory.CreateObject("X509Enrollment.CX500DistinguishedName"); objPrivateKey.ProviderName = "Microsoft Enhanced Cryptographic Provider v1.0"; objPrivateKey.KeySpec = "1"; objPrivateKey.ProviderType = "1"; try { objRequest.InitializeFromPrivateKey(1, objPrivateKey, template); objDN.Encode(sDistinguishedName, 0); objRequest.Subject = objDN; objEnroll.InitializeFromRequest(objRequest); sCertificate = objEnroll.CreateRequest(1); document.writeln(sCertificate); } catch (ex) { document.writeln(ex.description); } &lt;/script&gt; </code></pre> <p><strong>Couple of other questions</strong><br> - I assume that the template should exist on the Client Machine? Otherwise how does it know the location of the CA to query for templates?<br> - Does CertEnroll on a Client even work against a Windows 2003 CA server??</p> <p>If you can help me that it would be much appreciated!!!</p> <p><strong>Additional Info</strong><br> - Client is Windows 7, with MS IE9 Client running as Administrator.<br> - Web App which hosts the above page is accessed over HTTPs.<br> - Web App is hosted on a Win2003 CA Server.</p> <p><strong>Before posting I have looked at...</strong><br> - Stackoverflow threads regarding CertEnroll + InitializeFromPrivateKey<br> - <a href="http://www.sambeauvois.be/blog/2010/04/the-ix509certificaterequestpkcs10-initializefromtemplatename-adventure/" rel="nofollow">Blogs about using Template OID not Template name</a><br> - <a href="http://blogs.msdn.com/b/alejacma/archive/tags/certenroll/" rel="nofollow">MSDN / alejacma's Site</a><br> - CertEnroll API on MSDN</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload