title: How to create a minimal dummy X509Certificate2?
body: <p>I'm unit testing a .NET application; some of the unit tests involve programmatically generating X509Certificate2 objects.</p>
  
  <p>I don't care about actual signing/private key/validation stuff, I'd just like to have an object that doesn't throw exceptions when its fields are examined. I tried using the parameterless constructor, but then a whole bunch of fields throw exceptions when accessed. As seen in the debugger:</p>
  
  <p>SubjectName = '(new System.Collections.Generic.Mscorlib_CollectionDebugView(result.Certificates)).Items[0].SubjectName' threw an exception of type 'System.Security.Cryptography.CryptographicException'</p>
  
  <p>I also tried passing a byte array with some random numbers in it, but that didn't even construct (does the array need to be a specific size?)</p>
  
  <p>So, question: <strong>what is the simplest (fewest lines of code) way to programmatically generate an X509Certificate2 object which will not throw exceptions upon field/property accesses?</strong></p>