I'm working on an application written in C# where I basically need to act as my own certificate authority. The data flow is something like this:
- The end user generates a public/private key pair and sends me proof of their identity and a certificate request of some kind with their public key
- The app validates their ID
- When the validation is complete, the app generates an X.509 certificate, based on a local, self-signed root, and sends it to the user
- The user signs a file using the certificate, and sends the file to the app
- The app validates the file against the signature, and stores the results in SQL Server.
My questions:
- Do you know of a tutorial or code examples that describes how to create and use a X.509 certificate as described above, without relying on an external CA and without calling command line utilities or using COM objects? I've looked at the
X509Certificate2
class, but the examples in MSDN don't show what I'm after. - Is it possible to use SQL Server 2008+ to do some of the certificate handling? Perhaps using
CREATE CERTIFICATE FROM FILE
andBACKUP CERTIFICATE
? - If it can't be done with the standard Windows libraries, can it be done with the C# Bouncy Castle library? If so, are there some good code examples?