10

I have handler which creates jwt token with utilization of X509Certificate2. For unit test I need to provide certificate and it is not possible for me take it from the local store. Is there way, how to mock, create or load certificate from the file?

So far I tried BouncingCastle method from this ticket, but with no success. The method ToX509Certificate2() does convert certificate, but without keys. So if this is good way to go, is possible to generate these keys somehow?

Thanks a lot for hints

Community
  • 1
  • 1
Qerts
  • 935
  • 1
  • 15
  • 29
  • since its for unit testing I am guessing you can make a cert in your cert store and export it into a file for loading? – Steve Aug 24 '16 at 13:36

1 Answers1

8

As Steve suggested, I created my own certificate on the run. I utilised method from this ticket. Certificate is fully functional for purpose of testing.

Community
  • 1
  • 1
Qerts
  • 935
  • 1
  • 15
  • 29