Creating Certificates in C#

Certificates in C# 

 
The namespace responsible for all concepts is "System.Security" Furthermore, the namespace specific to the certification concept is "System.Security.Cryptography.X509Certificates". The X509Certificates class is mainly used to generate a certificate for an individual solution.

The System.Security.Cryptography.X509Certificates namespace contains the common language run time implementation of the Authenticode X.509 v.3 certificate. This certificate is signed with a private key that uniquely identifies the holder of the certificate.
 
Create a quick certificate from one resource file
  1. /First you need to get the contents of your resource file in which your encrypted data resides.    
  2. private MemoryStream getCertificate()    
  3. {    
  4.     String certificateFilePath = < Your resource file path > ;    
  5.     var readCertStream = new MemoryStream(File.ReadAllBytes(certificateFilePath));    
  6.     return readCertStream;    
  7. }    
  8. //Second call your previous method to generate the actual certificate    
  9. private X509Certificate readCertificate(MemoryStream argInputStream, string argCertificateType)    
  10. {    
  11.     X509Certificate certificate = null;    
  12.     t    
  13.     private X509Certificate readCertificate(MemoryStream argInputStream, string argCertificateType)    
  14.     {    
  15.         X509Certificate certificate = null;    
  16.         certificate = new X509Certificate(getCertificate().ToArray());    
  17.         return certificate;    
  18.     }    
  19. }   
In the certificate object you should have your actual certificate.
 
Happy Coding :)