title: X509 custom extensions - how do you set them?
body: <p>Despite doing a extensive search, I cannot find any examples of setting custom extensions (the <code>CustomExtensions</code> property) on a X509 (v3) certificate.</p>
  
  <p>If I want to generate a new certificate (based on an existing CA certificate already installed on the machine), how can I add custom extensions to it? I am looking to carry some extra custom information around in the certificate for later inspection. Can this be done programmatically or by using makecert? Or can these extensions only be set by writing a <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa387704%28v=vs.85%29.aspx" rel="nofollow">custom policy module</a> that is invoked when the certificate is generated? Can this even be achieved by using the regular <code>X509Certificate</code> or <code>X509Certificate2</code> classes from the .Net framework?</p>
  
  <p>I have found code to inspect the custom extensions, but none to set it. </p>